Skip to content

Instantly share code, notes, and snippets.

@shoghicp
Created April 6, 2014 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoghicp/10000160 to your computer and use it in GitHub Desktop.
Save shoghicp/10000160 to your computer and use it in GitHub Desktop.
<?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