systemctl .service ファイルが期待どおりに動作しません。

systemctl .service ファイルが期待どおりに動作しません。

Centos 7でサービスファイルを使用し、xymon用のサービスファイルを作成しています。私が経験している問題は、起動、停止、および再起動を設定しようとしていることです。可能であれば、既存のサービスファイルをテンプレートとして使用しますが、どのオプションを選択しても「停止」オプションが使用されます。

# more xymon.service
[Unit]
Description=Xymon Monitor Service
After=network.target
[Service]
Type=simple
#User=xymon
ExecStart=/home/xymon/startup/xymon-init.d start
ExecReload=/home/xymon/startup/xymon-init.d restart
ExecStop=/home/xymon/startup/xymon-init.d stop
[Install]
WantedBy=multi-user.target

私は単純なもの、分岐したもの、そしていくつかの他のバリエーションを試しましたが、役に立ちませんでした。最初のパラメータが印刷されるダミースクリプトが置かれ、常にログファイルで停止します。過去に他の種類のサービスファイルを問題なく実行したことがありますが、このsystemctlを試すのは今回が初めてです。どんな助けでも大変感謝します。

ベストアンサー1

注 - Argonautsの答えはいくつかのモードで動作します。私の環境の標準インストールに基づく作業バージョンは次のとおりです。

# xymonlaunch.service
# systemd file for Fedora 18 and up, or RHEL 7 and up

[Unit]
Description=Xymon systems and network monitor
Documentation=man:xymon(7) man:xymonlaunch(8) man:xymon(1)
After=network.target

[Install]
# Compatibility with "xymon" and "xymon-client"
Alias=xymon.service
Alias=xymon-client.service
WantedBy=multi-user.target


[Service]
#EnvironmentFile=/etc/sysconfig/xymonlaunch
User=xymon
# We wrap in xymoncmd to eliminate the need for the bulk of the old init script
ExecStart=/home/xymon/server/bin/xymoncmd /home/xymon/server/bin/xymonlaunch --no-daemon $XYMONLAUNCHOPTS
Type=simple

# Kill xymonlaunch, but don't send kills to the underlying procs, since they
# might be doing important things (like writing checkpoints and flushing caches)
KillMode=process
# SendSIGHUP=yes
SendSIGKILL=no

おすすめ記事