Supervisor deploys the go gin service or deploys it independently under Linux
- Supervisor deployment method
- supervisord installation
wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
sh setuptools-0.6c11-py2.7.egg
easy_install supervisor
echo_supervisord_conf >/etc/supervisord.conf
mkdir /etc/supervisord.conf.d
2.Modify the configuration /etc/supervisord.conf
[include]
files = /etc/supervisord.conf.d/*.conf
3.New management application
cd /etc/supervisord.conf.d
vim idphoto_server_lite_supervisor.conf
4.Configuration file:
command //Execute command
directory cd //Go to the specified directory
environment //environment variable configuration
copy code
[program:idphoto_server_lite]
command = ./main
directory = /data2/yingjie/go/idphoto_server_lite
autostart=true
autorestart=true
startretries=10 ; maximum number of retries on startup failure
startsecs = 5
user = root
redirect_stderr = true
stopsignal=QUIT ; signal used to kill process (default TERM)
stopwaitsecs=2 ; max num secs to wait b4 SIGKILL (default 10)
stopasgroup=true ; send stop signal to the UNIX process group (default false)
killasgroup=true ; SIGKILL the UNIX process group (def false)
stdout_logfile = /data2/yingjie/go/idphoto_server_lite/super_log/idphoto_server_lite_supervisor.log
environment=LD_LIBRARY_PATH=/data2/yingjie/go/idphoto_server_lite/c_library/idphoto/libs
5.supervisord management
5. supervisord management
After Supervisord is installed, there are two available command lines supervisord and supervisorctl. The command usage is explained as follows:
supervisord -c /etc/supervisord.conf Start supervisor for the first installation
supervisord, initially start Supervisord, start and manage the processes set in the configuration.
supervisorctl stop programxxx, stop a certain process (programxxx), programxxx is the value configured in [program:beepkg], this example is beepkg.
supervisorctl start programxxx, start a process
supervisorctl restart programxxx, restart a process
supervisorctl stop groupworker: , restart all processes belonging to the group named groupworker (same for start, restart)
supervisorctl stop all, stop all processes, note: start, restart, stop will not load the latest configuration file.
supervisorctl reload, load the latest configuration file, stop the original process and start and manage all processes according to the new configuration.
supervisorctl update, according to the latest configuration file, start a new configuration or a process with a change, and a process whose configuration has not been changed will not be affected and restarted.
Note: Display the process stopped with stop, and will not restart automatically with reload or update.
- Independent deployment under Linux
Deploying under linux, we can use the nohup command to deploy the application on the backend, as follows:
nohup ./beepkg &