2017-05-23 08:42
浏览 43


So to start; I am trying to launch a node application via PHP. I created a script that can check if the node application is running, close it and start it. But I have some trouble with using screen with PHP.

Now before I carry on, comments about how I shouldn't do it won't help, I need to have it launched via PHP, due to it working alongside a website, and I want our client to be able to change settings, which will relaunch the application (unless you have another idea).

I am currently using the command:

screen -dmS NODEJS node main.js 121016

Now I can launch node, and get the output (as long as I add a process.exit somewhere so PHP/Node doesn't run forever). I am already in the correct directory also, I am using this code to launch it:

$out = shell_exec('screen -dmS NODEJS node main.js 121016');

But it is not creating the screen session. I have also tried:

$proc = proc_open('screen -dmS NODEJS node main.js 121016', $this->pipe_spec, $pipes);

I also tried to use exec and the back ticks but I am fairly certain the back ticks are the same as shell_exec?

Anyway I am completely lost, and am not sure what else I can do. I don't want node constantly running, which is why I want it to launch when you click save in the manager (in php), and then it closes/stops itself when it has completed it's tasks.

Any help would go a long way, I have spent hours trying to work it out, but I am getting no where... thanks anyway.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题