public function handle()

in lib/php/libsdk/SDK/Build/PGO/Controller.php [72:114]


	public function handle($force)
	{
		/*$mode = (int)("init" !== $this->cmd);
		$mode = (PGOConfig::MODE_INIT == $mode && $force) ? PGOConfig::MODE_REINIT : $mode;
		$this->conf = new PGOConfig("init" !== $this->cmd);
		$this->conf->setScenario($this->scenario);*/
		$this->conf = $this->setupConfig($this->cmd);

		switch ($this->cmd) {
			default:
				throw new Exception("Unknown action '{$this->cmd}'.");
				break;
			case "init":
				$lk = new Lock("pgo_init");
				if (!$lk->locked()) {
					echo "Another process runs initialization right now, waiting.", PHP_EOL;
					$lk->exclusive(true);
					echo "Another process finished running initialization, I quit as well.", PHP_EOL;
					return;
				}
				$this->init($force);
				break;
			case "train":
				$lk = new Lock("pgo_train");
				if (!$lk->locked()) {
					echo "Another process runs training right now, I have to wait.", PHP_EOL;
					$lk->exclusive(true);
					echo "Another process finished training, I may continue.", PHP_EOL;
				}
				$this->train();
				break;
			case "up":
				$this->up();
				break;

			case "down":
				$this->down($force);
				break;
			case "check_init":
				// pass
				break;
		}
	}