private function createPtrackProcess($command, $args, $detached)
 {
     $taskId = md5(uniqid());
     if ($detached) {
         $this->systemTasks->setTaskStarting($taskId);
     }
     $socketPath = sprintf('/var/run/ptrack/%s.sock', $taskId);
     $dumpPath = sprintf(\Nethgui\Model\SystemTasks::PTRACK_DUMP_PATH, md5($socketPath));
     $cmd = strtr('/usr/libexec/nethserver/ptrack %detached -j -s %socketPath -d %dumpPath %verbose -- ', array('%detached' => $detached ? '-D' : '', '%verbose' => \NETHGUI_DEBUG ? '-v' : '', '%dumpPath' => \escapeshellarg($dumpPath), '%socketPath' => \escapeshellarg($socketPath))) . $this->prepareEscapedCommand($command, $args);
     $process = new \Nethgui\System\Process($cmd);
     $process->setEnv(array('LANG' => $this->getLangForProcess()));
     $process->setInput('{}');
     $process->taskId = $taskId;
     return $process;
 }
Exemple #2
0
 private function prepareInitializationView(\Nethgui\View\ViewInterface $view)
 {
     $firstRunningTask = \Nethgui\array_head(array_keys($this->systemTasks->getRunningTasks()));
     if ($firstRunningTask) {
         // Notify that the task is running:
         $this->notifications->trackerRunning(array('taskId' => $firstRunningTask));
         $view['trackerState'] = FALSE;
         $view['progress'] = FALSE;
         $view['message'] = '';
         return;
     }
     $firstStartingTask = \Nethgui\array_head(array_keys($this->systemTasks->getStartingTasks()));
     if ($firstStartingTask) {
         $view['progress'] = 0;
         $view['message'] = '...';
         $view['trackerState'] = array('dialog' => array('title' => $view->translate('Tracker_title_taskStarting'), 'action' => 'open'), 'location' => array('sleep' => 2000, 'url' => $view->getModuleUrl($firstStartingTask)));
         return;
     }
 }