4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

nem / symbolAdvent Calendar 2024

Day 7

Symbol Peer をサービス化(デーモン化)する

Last updated at Posted at 2024-12-06

サービスファイルの作成

Symbol Recovery

異常終了などで lock ファイルが残った際に起動します。

sudo vi /etc/systemd/system/symbol-recovery.service
/etc/systemd/system/symbol-recovery.service
[Unit]
Description=Symbol Recovery

[Service]
Type=oneshot
ExecCondition=/bin/sh -c '/usr/bin/test -f /opt/symbol-node/data/server.lock || /usr/bin/test -f /opt/symbol-node/data/broker.lock'
ExecStart=/usr/local/catapult/bin/catapult.recovery .
KillSignal=SIGINT
Restart=on-failure
RestartSec=2
TimeoutStopSec=60
User=harvestasya
Group=harvestasya
WorkingDirectory=/opt/symbol-node
Environment="LD_LIBRARY_PATH=/usr/local/catapult/deps"
StandardOutput=journal
StandardError=journal
LimitNOFILE=65536
UMask=077

[Install]
WantedBy=multi-user.target

Symbol Server

Symbol ノード本体を起動します。

sudo vi /etc/systemd/system/symbol.service
/etc/systemd/system/symbol.service
[Unit]
Description=Symbol Node
Wants=symbol-recovery.service
Requires=network.target

[Service]
Type=idle
ExecStart=/usr/local/catapult/bin/catapult.server .
KillSignal=SIGINT
Restart=on-failure
RestartSec=2
TimeoutStopSec=300
User=harvestasya
Group=harvestasya
WorkingDirectory=/opt/symbol-node
Environment="LD_LIBRARY_PATH=/usr/local/catapult/deps"
StandardOutput=journal
StandardError=journal
LimitNOFILE=65536
UMask=077

[Install]
WantedBy=multi-user.target

サービスをリロード

sudo systemctl daemon-reload

サービスを有効化

sudo systemctl enable symbol

サービスを開始

sudo systemctl start symbol

サービスを停止

sudo systemctl stop symbol

ログの確認

symbol サービスのみを参照します。最新から参照できるよう-rオプションを付けます。

sudo journalctl -u symbol -r

リアルタイムで確認したい場合は-fオプションを付けます。

sudo journalctl -u symbol -f

さらに色を付けたい場合は、-o catオプションを付けます。

sudo journalctl -u symbol -f -o cat

次回

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?