CentOS7にAEMのServiceを登録し、自動起動にする方法

CentOS7のサービスを手動で登録する場合は、/etc/systemd/systemに、(サービス名).serviceという名前の設定ファイルを作成します。

例えば、AEMのServiceを手動で登録する場合 aem.service という名前の設定ファイルを作成します。

$ vi /etc/systemd/system/aem.service

中身は、下記のように入力します。

[Unit]
Description=Adobe Experience Manager
After=network.target

[Service]
Type=simple
User=aem-service-user
ExecStart=/home/aem/crx-quickstart/bin/start
ExecStop=/home/aem/crx-quickstart/bin/stop
RemainAfterExit=yes
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target
  • User:AEM起動ユーザーID(※事前が必要です)
  • ExecStart:AEM起動スクリプトのパス
  • ExecStop:AEM停止スクリプトのパス

サービスの起動

$ sudo systemctl start aem.service

サービスのステータス確認

$ sudo systemctl status aem.service

サービスの停止

$ sudo systemctl stop aem.service

サービスの自動起動を有効にしますと、CentOSが起動される際に、AEMサービスも自動的に起動されます。

$ sudo systemctl enable aem.service
Created symlink from /etc/systemd/system/multi-user.target.wants/aem.service to /etc/systemd/system/aem.service.

サービスの自動起動設定を確認します。

$ sudo systemctl is-enabled aem.service
enabled

仮に、サービスの自動起動を無効に設定する場合、下記のコマンドを実行します。

$ sudo systemctl disable aem.service
Removed symlink /etc/systemd/system/multi-user.target.wants/aem.service.

サービス設定ファイルの再読込を忘れないでください。

$ sudo systemctl daemon-reload

これより、CentOSが起動される際に、AEMサービスも自動的に起動されます。

参照サイト

Systemd入門(4) - serviceタイプUnitの設定ファイル