Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supervisor managed node child_process spawn stdio inherit not working #1354

Open
CoreyCole opened this issue Jun 22, 2020 · 1 comment
Open
Labels

Comments

@CoreyCole
Copy link

CoreyCole commented Jun 22, 2020

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
Copy link
Author

Asked on stack overflow here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants