Closed FossPrime closed 6 years ago
I seem to have stumbled on a rabbit hole
My solution was to use spawn. The problem was pretending exec is just like a bash pty... it's not.
const { spawn } = require('child_process');
function handler(req, res, next) {
spawn( 'sudo', ['/etc/init.d/web-hooks', 'restart', '--force'], { detached:true, stdio:'ignore' }).unref()
}
P.S. if you are running on a server with less than 1.5gigs in memory.. letting the interpreter know may be useful to making sure it doesn't take memory from update processes. --max_old_space_size=512
. That said, I personally shut down node temporarily while updates run on the yum-cron file.
There doesn't seem to be a way to restart the script within node...
I can successfully kill the running app, but it won't start up again. I've tried nohup and exec
nohup makes no difference compared to running restart directly. Exec yields
sudo: exec: command not found
Has anyone figured this out? I'm trying to build a webhook handler that updates the webhook handler with a git pull and app restart.