Supervisor / supervisor

Supervisor process control system for Unix (supervisord)
http://supervisord.org
Other
8.46k stars 1.24k forks source link

supervisor managed node child_process spawn stdio inherit not working #1354

Open CoreyCole opened 4 years ago

CoreyCole commented 4 years ago

I'm managing a node server using supervisord on ubuntu 18.04

[program:MYSERVER]
user=ubuntu
directory=/home/ubuntu/my-server/
command=/bin/bash ./start-server.sh
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/server.out.log

In my node code, I am spawning a child process:

const child = child_process.spawn('./child-process.sh', [], {
    env: {
        PATH: `${process.env.PATH}`
    },
    detached: true,
    stdio: 'inherit'
});

When I run the node server normally (e.g. node server.js) everything works fine. When I start the process using supervisord, I get a few lines of stdout from the child-process.sh, but then the child process pauses execution.

It seems like the stdout buffer is full and the child process paused while waiting for a flush. But, I set the stdio: inherit so it should be automatically working, at least as I understand it.

I tried it both with detached: true and false. I tried stdio: pipe and I get no child stdout at all and pauses execution. I tried stdio: ignore and got the same results. I also tried nohup and foreverjs--same issue.

The only way I can disconnect my ssh connection with the server (super hacky workaround) is with a tmux screen. I start it in the screen in the background and everything works fine:

screen -dmS abc
screen -r abc
./start-server.sh > server.out 2>&1 &

Ideally, inherit works properly with some supervisord configuration. I'd like all my log messages in the same out file.

My child process script looks like this. It has httpie commands directing their output to /dev/null. Does that have something to do with this issue?

CoreyCole commented 4 years ago

Asked on stack overflow here :)