追加読書

追加読書

私はUbuntu 16.04 LTSでddclient / DDNSを使用して、私が所有している2つのドメイン(NameCheapから)のDNSレコードでIPを更新しています(動作します)。

しかし、問題はドメインが2つあるため、ddclientの2つの別々のインスタンスを実行する必要があることです。.serviceそのために、私は2つのファイルの作成を始めました。

/usr/lib/systemd/system/ddclient_website1.service

[Unit]
Description=DDNS client for website1.tld

[Service]
ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf

[Install]
WantedBy=multi-user.target

/usr/lib/systemd/system/ddclient_website2.service

[Unit]
Description=DDNS client for website2.tld

[Service]
ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website2.conf

[Install]
WantedBy=multi-user.target

ExecStart コマンドで指定された構成を次のように使用します。

/etc/ddclient_website1.conf

daemon=1800
use=web, web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=domain_1.tld
password=first_ddns_password
server_name

/etc/ddclient_website2.conf

daemon=1800
use=web, web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=domain_2.tld
password=second_ddns_password
server_name

systemctl enable ddclient_website1.service(website2と同じ)を使用すると、次のようになります。

Created symlink from /etc/systemd/system/multi-user.target.wants/ddclient_website1.service to /usr/lib/systemd/system/ddclient_website1.service.

systemctl start ddclient_website1.service出力を生成しません。

ps -ef | grep ddclient実行して作成したgrepを一覧表示しますsystemctl status ddclient_website1.service

● ddclient_website1.service - DDNS client for website1.tld
   Loaded: loaded (/usr/lib/systemd/system/ddclient_website1.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sun 2016-12-18 15:34:23 EST; 39s ago
  Process: 2687 ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf (code=exited, status=0/SUCCESS)
 Main PID: 2687 (code=exited, status=0/SUCCESS)

Dec 18 15:34:23 server_name systemd[1]: Started DDNS client for website1.tld.

再起動しても肯定的な変化は現れません。

編集する:

.serviceddclientのインストール中に生成されたデフォルトファイルにファイルを変更したら、.service次のことができます。スタートサービス(にリストされていますps -ef | grep ddclient

[Unit]
Description=DDNS client for website1.tld
After=network.target

[Service]
Type=forking
PIDFile=/var/run/ddclient_website1.pid
ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf

[Install]
WantedBy=default.target

ただし、40〜50秒間実行した後にタイムアウトし、アクセスする必要があるPIDファイルが存在しないことを示します(両方のサービスが同じ問題)。

● ddclient_website1.service - DDNS client for website1.tld
   Loaded: loaded (/usr/lib/systemd/system/ddclient_website1.service; enabled; vendor preset: enabled)
   Active: failed (Result: timeout) since Sun 2016-12-18 16:04:14 EST; 22s ago
  Process: 1347 ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf (code=exited, status=0/SUCCESS)

Dec 18 16:02:44 server_name systemd[1]: Starting DDNS client for website1.tld...
Dec 18 16:02:44 server_name systemd[1]: ddclient_website1.service: PID file /var/run/ddclient_website1.pid not readable (yet?) after start: No such file or directory
Dec 18 16:04:14 server_name systemd[1]: ddclient_website1.service: Start operation timed out. Terminating.
Dec 18 16:04:14 server_name systemd[1]: Failed to start DDNS client for website1.tld.
Dec 18 16:04:14 server_name systemd[1]: ddclient_website1.service: Unit entered failed state.
Dec 18 16:04:14 server_name systemd[1]: ddclient_website1.service: Failed with result 'timeout'.

私はtouch編集しddclient_website1.pid(ウェブサイト2でも動作します)、/var/run同じ結果を得ました。

ベストアンサー1

[提供する]
ExecStart=/usr/sbin/ddclient -ファイル/etc/ddclient_website1.conf

PIDFileプログラムのオプションと同様に、INIファイルの設定を使用するのは間違っています。多くのプログラムと同様に、このプログラムは実際には関連準備プロトコルを実装していません。Type=forking-pid

他の多くのソフトウェアと同様に、これを行う正しい方法はプログラムの-foregroundオプションを使用することです。 docoによると、このオプションはリビジョン113から利用可能です。

追加読書

おすすめ記事