Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
10
Help us understand the problem. What is going on with this article?
@tkhskt

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

More than 3 years have passed since last update.

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

10
Help us understand the problem. What is going on with this article?
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
tkhskt
ᕦ(ò_óˇ)ᕤ

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
10
Help us understand the problem. What is going on with this article?