
Fedora 23用のサービスデーモンを直接作成していますが、ソースライブラリが含まれているときにスクリプトがクラッシュしたときに停止します。
#!/bin/sh
#
# service-live-text-relation <summary>
#
# chkconfig: 2345 80 20
# description: Starts and stops a single service-live-text-relation instance on this system
#
### BEGIN INIT INFO
# Provides: service-live-text-relation
# Required-Start: $network $named
# Required-Stop: $network $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: This service manages the service-live-text-relation daemon
# Description: service-live-text-relation
### END INIT INFO
#
# init.d / servicectl compatibility (openSUSE)
#
if [ -f /etc/rc.status ]; then
. /etc/rc.status
rc_reset
fi
echo "test1"
#
# Source function library.
#
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
#. /etc/init.d/functions
echo "test2";
#... further code goes here ...
次のコマンドを実行します。
/bin/systemctl daemon-reload
chkconfig --add service-live-text-relation
chkconfig service-live-text-relation on
/bin/systemctl enable service-live-text-relation.service
私が実行したとき:
service service-live-text-relation start
次の結果が表示されます。
test1
Starting service-live-text-relation (via systemctl):
そしてスクリプトが中断されます...
例に従い、別のスクリプトを見ましたが、私のスクリプトにどのようなエラーがあるかを特定することはできません。
答え1
私は、システム互換性の問題に苦しんでいると思います。 systemdサポートシステムでは、/etc/init.dのファイルはsystemdによって処理されます。 「service」コマンドは、「かわいい」(助けになる)方法でサービスを開始しようとするシェルスクリプトです。 「/etc/init.d/service-live-text-relation」を手動で実行してみましたか?
システムの互換性がどのように機能するかわからないので、お手伝いできません。他のinit.dサービス制御スクリプトのように、正しい「開始」、「停止」、「再起動」(など)のターゲットがある場合は、それを機能させることができると確信しています。
しかし、あなたは本物システム単位のファイルを生成する必要があります。 /etc/systemd/userに「service-live-text-relation.service」という単位ファイルを追加してみてください。 「man systemd.service」(およびすべての友人)を確認してください。システム化された世界になっているので、スタートアップファイルを更新することをお勧めします。 IMHO。