Help us understand the problem. What is going on with this article?

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

More than 1 year has 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で簡単にデーモン化

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
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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