スーパーバイザーの監督下でサービスを開始することについての考え方は、単一のデーモンの下で複数のサービスを実行できるようにすることです。スーパーバイザーの構成に応じて、子プロセスとして特定のサービスを開始、停止、または再起動できます。この設定では、apache2
を実行する方法を示します Ubuntu / Debian Linuxでの監視対象サービス(Dockerイメージなどに役立ちます)として。
まず、スーパーバイザーをインストールします:
# apt-get install supervisor
apache2
を含める のスーパーバイザー構成を/etc/supervisor/conf.d/
に 。スーパーバイザーは、このディレクトリから構成ファイルを選択します。このファイルの要件は、*.conf
のみです。 ファイル拡張子。たとえば、次の行を新しいファイル/etc/supervisor/conf.d/apache2.conf
に挿入します。 :
[program:apache2] command=/usr/sbin/apache2ctl -DFOREGROUND
上記の設定ファイルを含めたら、apache2 Webサーバーが現在実行されている場合は停止します:
# /etc/init.d/apache2 stop [ ok ] Stopping web server: apache2. root@4e004b451a98:/# /etc/init.d/apache2 status [FAIL] apache2 is not running ... failed!
スーパーバイザーを再起動します:
# /etc/init.d/supervisor restart Restarting supervisor: supervisord.
スーパーバイザーを再起動したら、apache2Webサーバーも起動する必要があります。 apache2ウェブサーバーが実行されていることを確認します:
# /etc/init.d/apache2 status [ ok ] apache2 is running.
トラブルシューティング
何らかの理由で、nodaemon
のスーパーバイザー実行スーパーバイザーの下でapacheを実行できない場合 モード:
# /etc/init.d/supervisor stop Stopping supervisor: supervisord. # supervisord -n
エラーメッセージ:
/usr/lib/python2.7/dist-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security. 'Supervisord is running as root and it is searching ' 2015-05-07 01:21:00,849 CRIT Supervisor running as root (no user in config file) 2015-05-07 01:21:00,849 WARN Included extra file "/etc/supervisor/conf.d/apache2.conf" during parsing 2015-05-07 01:21:00,858 INFO RPC interface 'supervisor' initialized 2015-05-07 01:21:00,858 CRIT Server 'unix_http_server' running without any HTTP authentication checking 2015-05-07 01:21:00,858 INFO supervisord started with pid 542 2015-05-07 01:21:01,862 INFO spawned: 'apache2' with pid 545 2015-05-07 01:21:01,914 INFO exited: apache2 (exit status 0; not expected) 2015-05-07 01:21:02,918 INFO spawned: 'apache2' with pid 548 2015-05-07 01:21:02,970 INFO exited: apache2 (exit status 0; not expected) 2015-05-07 01:21:04,975 INFO spawned: 'apache2' with pid 551 2015-05-07 01:21:05,025 INFO exited: apache2 (exit status 0; not expected) 2015-05-07 01:21:08,031 INFO spawned: 'apache2' with pid 554 2015-05-07 01:21:08,078 INFO exited: apache2 (exit status 0; not expected) 2015-05-07 01:21:09,079 INFO gave up: apache2 entered FATAL state, too many start retries too quickly
上記のエラーメッセージが表示された場合は、ApacheWebサーバーがまだ実行されていないことを確認してください。
表示される可能性のある別のエラーメッセージは次のとおりです。
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf: Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
これは、apache2
を実行しようとしているためです。 直接コマンド。 apache2ctl
を実行してみてください 代わりに。