public function switchWebSocketOn($params) { $wDir = $this->getPluginWorkDir(true); $pidFile = $wDir . DIRECTORY_SEPARATOR . "ws-pid"; if (file_exists($pidFile)) { $pId = file_get_contents($pidFile); $unixProcess = new UnixProcess(); $unixProcess->setPid($pId); $status = $unixProcess->status(); if ($status) { throw new Exception("Web Socket server seems to already be running!"); } } $host = escapeshellarg($params["WS_SERVER_BIND_HOST"]); $port = escapeshellarg($params["WS_SERVER_BIND_PORT"]); $path = escapeshellarg($params["WS_SERVER_PATH"]); $cmd = ConfService::getCoreConf("CLI_PHP") . " ws-server.php -host=" . $host . " -port=" . $port . " -path=" . $path; chdir(AJXP_INSTALL_PATH . DIRECTORY_SEPARATOR . AJXP_PLUGINS_FOLDER . DIRECTORY_SEPARATOR . "core.mq"); $process = AJXP_Controller::runCommandInBackground($cmd, null); if ($process != null) { $pId = $process->getPid(); $wDir = $this->getPluginWorkDir(true); file_put_contents($wDir . DIRECTORY_SEPARATOR . "ws-pid", $pId); return "SUCCESS: Started WebSocket Server with process ID {$pId}"; } return "SUCCESS: Started WebSocket Server"; }
protected function informWatcher($action, $path) { $cmd = "python " . $this->getBaseDir() . "/framework_watch.py --action={$action} --path=" . escapeshellarg($path); AJXP_Controller::runCommandInBackground($cmd, $this->getBaseDir() . "/cmd.out"); }