LoginSignup
2
2

More than 5 years have passed since last update.

任意のプログラム(ここではFLEXlm)をデーモン化する方法 (一部CentOS向け)

Posted at

ある実行ファイルをデーモン化して常時起動させるとき、便利な方法について述べています。

いくらでも記事はあると思いますが、ライセンスサーバのflexlmへの事例をご紹介します。

systemdにしたり、init.dとかめんどくさくない?ということで、daemonizeするツールが便利です。
supervisorをご紹介します。

supervisord のインストール

supervisorは、プロセス管理のツールです。
CentOS7ならば、epelを入れることで、パッケージで入れることが出来ます。

yum -y install epel-release
yum -y install supervisor

ついでにやっておくと便利なこと childlogdirの変更。

/etc/supervisord.conf (childlogdir行を追加しています)

[supervisord]
;nocleanup=true              ; (don't clean up tempfiles at start;default false)
;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
childlogdir=/var/log/supervisor

childlogdirを設定しておくと管理するプロセスごとに標準出力のログが吐かれるので便利です。
/var/log/supervisorにしておくと、logrotateも効くので二重で良いです。

supervisord の自動起動化と起動

systemctl enable supervisord
systemctl start supervisord

プロセス管理ファイルの追加

事前に /etc/supervisord.conf

[include]
files = supervisord.d/*.ini

がどうなっているか確認しましょう。
CentOSでは、デフォルトで*.ini、debianでは、デフォルトで *.confです。

/etc/supervisord.d/lmgrd.ini

[program:lmgrd]
user=%username%
autostart=true
autorestart=true
directory=/opt
command=/opt/lmgrd -z -c %licfile%
startretries=10000

/opt に置いている前提ですが、好きなディレクトリにしましょう
1024未満のポート番号ではないので、一般ユーザでもポートを開くことができます。
%username%に作った一般ユーザを名を入れて下さい。
%licfile%にベンダーから貰ったライセンスファイルを、相対パスか絶対パスで指定します。

2
2
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
2
2