#topicpath
----


**Processをデーモン化する、Supervisor [#k0c64259]
下記でインストールできます。
 sudo apt-get install supervisor
#contents

***finallyがよばれない?? [#zbe6d819]
Linux上で、sudo kill した場合、try/finallyのfinallyがよばれないっぽい。フォアグラウンドで実行してctrl+cした場合は問題ないのですが。。

以下殴り書きメモ:
import sys,signalしといて

こんな定義ファイルを書いておいて、
 $ cat /etc/supervisor/conf.d/temp_disp.conf 
 [program:temp_disp]
 command=sudo python3 /home/pi/samples/temp_disp.py
 numprocs=1
 redirect_stderr=true
 stdout_logfile=/var/log/temp_disp.log
 user=pi
 def cleanup(*args):
     sys.exit(0)
 signal.signal(signal.SIGINT, cleanup)
 signal.signal(signal.SIGTERM, cleanup)

定義ファイル読み込みとサービスの追加(初回だけ)
 $ sudo supervisorctl reread
 temp_disp: available
 $ sudo supervisorctl add temp_disp
 temp_disp: added process group
とか書いておくと、よばれるようになりますが、コレでいいのかな。。。

ステータス確認
 $ sudo supervisorctl status
 temp_disp                        RUNNING    pid 25258, uptime 0:00:05
 $ sudo supervisorctl stop temp_disp
 temp_disp: stopped
 
 
デーモンの追加と削除は、
 $ sudo supervisorctl add temp_disp
 $ sudo supervisorctl remove temp_disp

デーモンの起動と停止は、
 $ sudo supervisorctl start temp_disp
 $ sudo supervisorctl stop temp_disp
----
この記事は
#vote(おもしろかった,そうでもない)

#comment

-[[Supervisor: A Process Control System ― Supervisor 3.3.1 documentation>http://supervisord.org/]]
#topicpath

SIZE(10){現在のアクセス:&counter;}


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS