9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2018-02-16

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で簡単にデーモン化

9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?