From 95345b673ae9c3626108774836ee6d1c0cb2f361 Mon Sep 17 00:00:00 2001 From: anastasia prasolova Date: Wed, 6 Nov 2019 16:09:07 +0300 Subject: [PATCH] added systemd unit file and target for make --- Makefile | 15 +++++++++++++++ neo-go.service | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 neo-go.service diff --git a/Makefile b/Makefile index f37bf24e4..b8d742442 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,21 @@ build: deps && export CGO_ENABLED=0 \ && go build -v -mod=vendor -ldflags $(BUILD_FLAGS) -o ${BINARY} ./cli/main.go +install: build + @echo "=> Preparing directories and configs" + @id neo-go || useradd -s /usr/sbin/nologin -d /var/lib/neo-go neo-go \ + && mkdir -p /var/lib/neo-go \ + && chown -R neo-go:neo-go /var/lib/neo-go + @echo "=> Installing systemd service" + @mkdir -p /etc/neo-go \ + && mkdir -p /etc/systemd/system/ \ + && cp ./neo-go.service /etc/systemd/system/ \ + && cp ./config/protocol.mainnet.yml /etc/neo-go \ + && systemctl enable neo-go.service \ + && mv ./bin/neo-go /usr/local/bin/neo-go \ + && chown neo-go:neo-go /usr/local/bin/neo-go + @echo "Done. Start Neo Go with 'systemctl start neo-go.service'" + image: @echo "=> Building image" @docker build -t cityofzion/neo-go:latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . diff --git a/neo-go.service b/neo-go.service new file mode 100644 index 000000000..2bb69c468 --- /dev/null +++ b/neo-go.service @@ -0,0 +1,18 @@ +[Unit] +Description=Neo Go node +Requires=network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/neo-go node --mainnet --config-path=/etc/neo-go +User=neo-go +Group=neo-go +Restart=always +RestartSec=5 +StandardError=syslog +SyslogIdentifier=neo-go +PrivateTmp=true +WorkingDirectory=/var/lib/neo-go + +[Install] +WantedBy=multi-user.target