10
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Organization

GoアプリケーションをSupervisorでデーモン化😘

Goは言語レベルでのデーモン化がサポートされていない(らしい)のでSupervisorやsystemdでデーモン化します。

Supervisorの導入

sudo apt-get install supervisor

Goアプリケーションのビルド

go build hoge

supervisord.confの編集

sudo vim /etc/supervisor/supervisord.conf

以下を追記

[program:hoge]
command = /path/to/hoge
autostart = true
startsecs = 5
user = root
redirect_stderr = true

supervisorの実行

sudo supervisord

エラーが出たら

Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.

こいつが出たら

ps -ef | grep supervisord

を実行

root     17310     1  0 05:40 ?        00:00:02 /usr/bin/python /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
pi       17638 16611  0 06:17 pts/0    00:00:00 grep --color=auto supervisord

pidを確認してkillする

kill 17310

参考

Supervisor を利用して Go アプリケーションをデーモン化する
Supervisorで簡単にデーモン化

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
10
Help us understand the problem. What are the problem?