Example #1
0
 public static function start($jsfile, $params = "")
 {
     $cmd = realpath(Yii::getPathOfAlias('webroot') . '/' . trim($jsfile, '/'));
     if (is_file($cmd)) {
         NodeProcess::checkNode();
         $pid = null;
         if (substr(php_uname(), 0, 7) == "Windows") {
             exec("plansys\\commands\\shell\\psexec.exe -accepteula -d node " . $cmd . " " . $params, $output, $input);
             $pid = $input;
         } else {
             $pid = exec("nodejs " . $cmd . " " . $params . " > /dev/null 2>&1 & echo \$!;", $output, $input);
         }
         NodeProcess::addPid($pid);
         return $pid;
     } else {
         throw new CException("File Not Found " . $cmd);
     }
 }