Created
April 6, 2014 01:13
-
-
Save shoghicp/10000160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PocketMineInstance extends Thread{ | |
public $cwd; | |
public $args; | |
public function __construct($workingDirectory, $args){ | |
$this->cwd = realpath($workingDirectory) . "/"; | |
$this->args = $args; | |
$this->start(PTHREADS_INHERIT_NONE); | |
} | |
public function run(){ | |
chdir($this->cwd); | |
$argv = explode(" ", $args); | |
arrat_unshift($argv, $this->cwd . "PocketMine-MP.php"); | |
$argc = count($args); | |
require($this->cwd . "PocketMine-MP.php"); | |
} | |
} | |
//Warning: each instance MUST use a different port. | |
$instances = array( | |
"folder/to/PocketMine/instance/" => "--argument=value --server-port=19132", | |
"another/folder/to/PocketMine/instance/" => "--argument=value --server-port=19133", | |
); | |
$threads = array(); | |
foreach($instances as $wd => $args){ | |
$threads[$wd] = new PocketMineInstance($wd, $args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment