Answer the question
In order to leave comments, you need to log in
How to make yii2 console command work all the time in Ubuntu Server?
In an application developed on the PHP yii2 framework, it is required to ensure the constant operation of the console command (WebSocket connection) - both starting when the server is restarted, and resuming work if the connection (command operation) has fallen off for some reason.
In manual mode, running a command looks like this:
cd /var/www/project
./yii example/command
If you exit the console (or ctrl + z), the command stops running.
How to do it right?
Answer the question
In order to leave comments, you need to log in
Liked the solution above. + you can also add screen and, of course, daemonization. This is a more correct approach.
The most convenient way to do this is with supervisord
. But for special cases, it can be redundant.
Set up a daemon using supervisord.org (it's convenient to monitor the process from the web panel: status, restart, uptime)
Command executed by supervisord: nohup ./yii example/command 2>&1 &
Thanks everyone for the comments.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question