public function actionStart($name, $message) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; try { // $name = Yii::$app->request->post('name'); // $message = Yii::$app->request->post('message'); // var_dump(Yii::$app->request->post()); // var_dump(Yii::$app->request->getBodyParams()); // var_dump($name); // var_dump($message); // $name = Yii::$app->request->getQueryParam('name'); // $message = Yii::$app->request->getQueryParam('message'); if ($name && $message) { // $chatCommand = PHP_BINDIR . '/php ' . Yii::getAlias('@appRoot/yii') . // " chat/index --name={$name} --message={$message}"; $chatCommand = PHP_BINDIR . '/php ' . Yii::getAlias('@appRoot/yii') . " chat/index {$name} {$message}"; $chatProcess = new Process($chatCommand); $chatPid = $chatProcess->getPid(); Yii::$app->session->set('chatPid', $chatPid); return ['status' => 'ok', 'msg' => 'Все ништяк!!!']; } } catch (Exception $e) { return ['status' => 'error', 'msg' => $e->getMessage()]; } return ['status' => 'error', 'msg' => 'Произошла ошибка!!!']; } else { throw new BadRequestHttpException(Yii::t('common', "Запрос не ajax'овский!!!")); } }
public function actionStart() { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; try { // Запуск демона и получение PID (предполагается, // что pid где-то сохраняется после запуска) // /usr/bin/php /h $command = PHP_BINDIR . '/php ' . Yii::getAlias('@appRoot/yii') . ' basic/index'; $process = new Process($command); $processId = $process->getPid(); Yii::$app->session->set('processId', $processId); return ['status' => 'ok', 'msg' => 'Все ништяк!!!']; } catch (Exception $e) { return ['status' => 'error', 'msg' => $e->getMessage()]; } } else { throw new BadRequestHttpException(Yii::t('common', "Запрос не ajax'овский!!!")); } }
public function actionStart() { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; try { $nodeCommand = 'node ' . Yii::getAlias('@nodejs') . DIRECTORY_SEPARATOR . 'fileServer.js'; $nodeProcess = new Process($nodeCommand); $nodePid = $nodeProcess->getPid(); Yii::$app->session->set('fileNodePid', $nodePid); $fileCommand = PHP_BINDIR . '/php ' . Yii::getAlias('@appRoot/yii') . " file"; $fileProcess = new Process($fileCommand); $filePid = $fileProcess->getPid(); Yii::$app->session->set('filePid', $filePid); return ['status' => 'ok', 'msg' => 'Все ништяк!!!']; } catch (Exception $e) { return ['status' => 'error', 'msg' => $e->getMessage()]; } } else { throw new BadRequestHttpException(Yii::t('common', "Запрос не ajax'овский!!!")); } }