From 21415a98472f3e7f1f5349b1ca3976096aaa2614 Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Thu, 28 May 2020 16:48:06 -0400 Subject: [PATCH 1/4] add chainwatch systemd svc config; make install-chainwatch-service --- Makefile | 8 ++++++++ scripts/chainwatch.service | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 scripts/chainwatch.service diff --git a/Makefile b/Makefile index 92772ab19..fdf9e7e09 100644 --- a/Makefile +++ b/Makefile @@ -114,6 +114,7 @@ install-services: install clean-services: rm -f /usr/local/lib/systemd/system/lotus-daemon.service rm -f /usr/local/lib/systemd/system/lotus-miner.service + rm -f /usr/local/lib/systemd/system/chainwatch.service systemctl daemon-reload # TOOLS @@ -160,6 +161,13 @@ chainwatch: .PHONY: chainwatch BINS+=chainwatch +install-chainwatch-service: chainwatch + install -C ./chainwatch /usr/local/bin/chainwatch + install -C -m 0644 ./scripts/chainwatch.service /usr/local/lib/systemd/system/chainwatch.service + systemctl daemon-reload + @echo + @echo "chainwatch installed. Don't forget to 'systemctl enable chainwatch' for it to be enabled on startup." + bench: rm -f bench go build -o bench ./cmd/lotus-bench diff --git a/scripts/chainwatch.service b/scripts/chainwatch.service new file mode 100644 index 000000000..47af6b59e --- /dev/null +++ b/scripts/chainwatch.service @@ -0,0 +1,12 @@ +[Unit] +Description=Chainwatch +After=lotus-daemon.service +Requires=lotus-daemon.service + +[Service] +ExecStart=/usr/local/bin/chainwatch run +Environment=LOTUS_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" +Environment=LOTUS_PATH="/root/.lotus" + +[Install] +WantedBy=multiuser.target From c0cdcbb9e0b51b16a0db5832c36df9ba713d54df Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Thu, 4 Jun 2020 08:09:01 -0400 Subject: [PATCH 2/4] Adjust service logging and startup settings --- Makefile | 3 ++- scripts/chainwatch.service | 5 ++++- scripts/lotus-daemon.service | 6 +++--- scripts/lotus-miner.service | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index fdf9e7e09..5db557d7e 100644 --- a/Makefile +++ b/Makefile @@ -105,11 +105,12 @@ install: install-services: install mkdir -p /usr/local/lib/systemd/system + mkdir -p /var/log/lotus install -C -m 0644 ./scripts/lotus-daemon.service /usr/local/lib/systemd/system/lotus-daemon.service install -C -m 0644 ./scripts/lotus-miner.service /usr/local/lib/systemd/system/lotus-miner.service systemctl daemon-reload @echo - @echo "lotus and lotus-miner services installed. Don't forget to 'systemctl enable lotus|lotus-miner' for it to be enabled on startup." + @echo "lotus-daemon and lotus-miner services installed. Don't forget to 'systemctl enable lotus-daemon|lotus-miner' for it to be enabled on startup." clean-services: rm -f /usr/local/lib/systemd/system/lotus-daemon.service diff --git a/scripts/chainwatch.service b/scripts/chainwatch.service index 47af6b59e..e958ec857 100644 --- a/scripts/chainwatch.service +++ b/scripts/chainwatch.service @@ -1,12 +1,15 @@ [Unit] Description=Chainwatch +PartOf=sentinel.service After=lotus-daemon.service Requires=lotus-daemon.service [Service] -ExecStart=/usr/local/bin/chainwatch run +Environment=GOLOG_FILE="/var/log/lotus/chainwatch.log" +Environment=GOLOG_LOG_FMT="json" Environment=LOTUS_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" Environment=LOTUS_PATH="/root/.lotus" +ExecStart=/usr/local/bin/chainwatch run [Install] WantedBy=multiuser.target diff --git a/scripts/lotus-daemon.service b/scripts/lotus-daemon.service index 46bc47bdb..99a94e217 100644 --- a/scripts/lotus-daemon.service +++ b/scripts/lotus-daemon.service @@ -1,15 +1,15 @@ [Unit] Description=Lotus Daemon After=network-online.target -Wants=network-online.target +Requires=network-online.target [Service] -Environment=GOLOG_FILE="/var/log/lotus-daemon" +Environment=GOLOG_FILE="/var/log/lotus/daemon.log" Environment=GOLOG_LOG_FMT="json" ExecStart=/usr/local/bin/lotus daemon #ExecStop=/bin/sh -a -c /root/capture_lotus_heap.sh Restart=always -RestartSec=30 +RestartSec=10 MemoryAccounting=true MemoryHigh=8G diff --git a/scripts/lotus-miner.service b/scripts/lotus-miner.service index 7b866e043..3a460450f 100644 --- a/scripts/lotus-miner.service +++ b/scripts/lotus-miner.service @@ -2,10 +2,11 @@ Description=Lotus Storage Miner After=network.target After=lotus-daemon.service +Requires=lotus-daemon.service [Service] ExecStart=/usr/local/bin/lotus-storage-miner run -Environment=GOLOG_FILE="/var/log/lotus-miner" +Environment=GOLOG_FILE="/var/log/lotus/miner.log" Environment=GOLOG_LOG_FMT="json" [Install] From ce30162907c8d774a6b8e711bfccfa2e26b02651 Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Thu, 4 Jun 2020 08:10:08 -0400 Subject: [PATCH 3/4] Fix documentation link for new systemd page --- documentation/en/.library.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/en/.library.json b/documentation/en/.library.json index 018e6189b..293c871ea 100644 --- a/documentation/en/.library.json +++ b/documentation/en/.library.json @@ -58,8 +58,8 @@ }, { "title": "Use Lotus with systemd", - "slug": "en+install-system-services", - "github": "en/install-system-services.md", + "slug": "en+install-systemd-services", + "github": "en/install-systemd-services.md", "value": null }, { From 8649baccf7625c61f3619e778926ff4c02e0bb1c Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Thu, 18 Jun 2020 22:18:31 -0400 Subject: [PATCH 4/4] Remove dev values from chainwatch.service --- scripts/chainwatch.service | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/chainwatch.service b/scripts/chainwatch.service index e958ec857..74afee0e9 100644 --- a/scripts/chainwatch.service +++ b/scripts/chainwatch.service @@ -1,15 +1,15 @@ [Unit] Description=Chainwatch -PartOf=sentinel.service After=lotus-daemon.service Requires=lotus-daemon.service [Service] Environment=GOLOG_FILE="/var/log/lotus/chainwatch.log" Environment=GOLOG_LOG_FMT="json" -Environment=LOTUS_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" -Environment=LOTUS_PATH="/root/.lotus" +Environment=LOTUS_DB="" +Environment=LOTUS_PATH="%h/.lotus" +EnvironmentFile=-/etc/lotus/chainwatch.env ExecStart=/usr/local/bin/chainwatch run [Install] -WantedBy=multiuser.target +WantedBy=multi-user.target