public function setUp()
 {
     $this->configHandler = $this->getMockBuilder(ConfigFileHandler::class)->disableOriginalConstructor()->getMock();
     $this->configHandler->method('createConfig')->willReturn(true);
     $this->processConfig = $this->getMockBuilder(ProcessConfig::className())->disableOriginalConstructor()->setMethods(null)->getMock();
     $this->testProcessConfig = "command=test-command\n                process_name=%(program_name)s_%(process_num)02d\n                numprocs=2\n                numprocs_start=0\n                priority=999\n                autostart=1\n                startsecs=2\n                startretries=4\n                autorestart=unexpected\n                exitcodes=2\n                stopsignal=TERM\n                stopwaitsecs=15";
     $this->processConfig->setConfigHandler($this->configHandler);
 }
 public function saveGroup()
 {
     $processConfig = new ProcessConfig($this->groupName);
     return $processConfig->createGroup($this->attributes) ? true : false;
 }
 public function actionProcessConfigControl()
 {
     $request = \Yii::$app->request;
     $actionType = $request->post('actionType');
     $response = ['isSuccessful' => true];
     try {
         $group = new ProcessConfig($request->post('groupName'));
         if ($group->hasMethod($actionType)) {
             $group->{$actionType}();
         }
         Event::trigger(Supervisor::className(), Supervisor::EVENT_CONFIG_CHANGED);
     } catch (SupervisorException $error) {
         $response = ['isSuccessful' => false, 'error' => $error->getMessage()];
     }
     return $response;
 }