デーモンを再ロードしないと、起動時にSymlinked systemdスクリプトが起動しません。

デーモンを再ロードしないと、起動時にSymlinked systemdスクリプトが起動しません。

バージョン管理下の起動スクリプトを含むCentOS 7にカスタムシステムサービスがあります/srv/etc/systemd/website.service

[Unit]
Description=website
After=syslog.target network.target

[Service]
Type=forking
User=website
ExecStart=/opt/perl5/perls/perl-5.20.2/bin/hypnotoad /var/www/domains/<domain>/script/site.pl
ExecStop=/opt/perl5/perls/perl-5.20.2/bin/hypnotoad --stop /var/www/domains/<domain>/script/site.pl

[Install]
WantedBy=multi-user.target

実行すると、systemctl enable /srv/etc/systemd/website.serviceシンボリックリンクが正しく作成され実行され、systemctl start websiteサービスが開始されますが、[Install]セクションが欠落していると文句を言いますが、これは明らかに間違っています。

$ sudo systemctl enable /srv/etc/systemd/website.service 
Created symlink from /etc/systemd/system/website.service to /srv/etc/systemd/website.service.
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).

再起動後、サービスは開始されずにsystemctl start website返されましたFailed to start website.service: Unit not found。を実行すると、systemctl daemon-reloadコマンドstartは再び機能します。

しかし、もし私がコピーファイルを/etc/systemd/systemに入れて実行すると、すべてがsystemctl enable website期待どおりに機能し、再起動後すぐにサービスが開始されました。

私が望むことを実際に行うことは可能ですか、それとも変更を適用するときにGitリポジトリからシステムスクリプトを手動でコピーする必要があることを覚えておくべきですか?

ベストアンサー1

サービスの開始時にシンボリックリンクが参照するドライブがマウントされていることを確認する必要があります。

おすすめ記事