官术网_书友最值得收藏!

Installing supervisord

We can easily install supervisord on Ubuntu 16.04, with the apt-get command:

sudo apt-get install -y supervisor

This installs two tools, supervisor and supervisorctl. supervisorctl is intended to control the supervisord and add tasks, restart tasks, and so on.

On macOS X, we can install supervisor using the brew command:

brew install supervisor

Now, create a configuration file at:

/etc/supervisor/conf.d/goproject.conf

You can add any number of configuration files, and supervisord treats them as separate processes to run. Add the following content to the preceding file:

[supervisord]
logfile = /tmp/supervisord.log
[program:myserver]
command=$GOPATH/bin/romanserver
autostart=true
autorestart=true
redirect_stderr=true

By default, we have a file called .supervisord.conf at /etc/supervisor/. Look at it for more reference. In macOS X, the same file will be located at /usr/local/etc/supervisord.ini.

Coming to the preceding configuration:

  • The [supervisord] section tells the location of the log file for supervisord
  • [program:myserver] is the task block which traverses to the given directory and executes the command given

Now we can ask our supervisorctl to re-read the configuration and restart the tasks (process). For that, just say:

  • supervisorctl reread
  • supervisorctl update

Then, launch supervisorctl with the command:

supervisorctl

You will see something like this:

supervisorctl is a great tool for controlling supervisor programs.

   

Since we named our romanserver myserver in the supervisor configuration file, we can start, stop, and restart that program from supervisorctl.

主站蜘蛛池模板: 大兴区| 虎林市| 北海市| 靖安县| 望江县| 通辽市| 荔波县| 内江市| 本溪市| 广南县| 大连市| 汝城县| 博野县| 永福县| 南溪县| 阿荣旗| 蒙阴县| 定西市| 高邮市| 崇阳县| 越西县| 昔阳县| 温州市| 宁远县| 宣城市| 武胜县| 盈江县| 内黄县| 临武县| 翼城县| 黄梅县| 溧水县| 准格尔旗| 大连市| 隆德县| 罗江县| 东莞市| 松溪县| 濉溪县| 本溪市| 湟源县|