How to start waitress-server in Background?

Asked

Viewed 54 times

2

I am trying to start the waitress-serve server in a Flask application. For this I use:

waitress-serve --call --listen=0.0.0.0:5000 app:create_app

However when the server starts it hangs the console output. How can I start the service in Background, to release the console and continue a sequence of commands, if I need, for example?

2 answers

2


With the following command:

waitress-serve --call --listen=0.0.0.0:5000 app:create_app >> log.txt & 

This way, you redirect the log output to log.txt and & force run in the background. ;)

2

Just improving the friend’s response @Igor-Cavalcanti. If you just run with >> log.txt & does not guarantee that it will continue running in the background after you terminate your session at the terminal, it will only direct the STOUT to the file log.txt, and will be active until you terminate your session. When you close the terminal, the process is also terminated.

The right thing to do in this case, to run in the background - even after the session is over - would be to use nohup

According to the Wikipedia:

nohup is a UNIX command that allows you to run a program in a form "disconnected" from the current session. That is, if the user logs out, the command will continue to run in the background, issuing its output to the file nohup.out

That is, even if you disconnect from the terminal, your command will continue running on the server, which I believe is the reason you want it. So the final command would be:

nohup waitress-serve --call --listen=0.0.0.0:5000 app:create_app &

Note that there is no >> log.txt once the nohup will save the output in the file nohup.out

Browser other questions tagged

You are not signed in. Login or sign up in order to post.