From 161ec76eb924ecd565918cc7dbc7b7f89cfaaf77 Mon Sep 17 00:00:00 2001 From: Paulo Truta Date: Sat, 11 Mar 2023 13:58:54 +0100 Subject: [PATCH] Add service file and install command (#27) * Added systemd service file * Added make install command (copies binary to local bin and adds service file * Makefile has intall-prod and install-cloud commands --- Makefile | 14 ++++++++++++++ edgeboxctl.service | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 edgeboxctl.service diff --git a/Makefile b/Makefile index bcabf7f..f8be198 100644 --- a/Makefile +++ b/Makefile @@ -33,3 +33,17 @@ test: test-with-coverage: go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out + +install-cloud: build-cloud + cp ./bin/edgeboxctl /usr/local/bin/edgeboxctl + cp ./edgeboxctl/edgeboxctl.service /lib/systemd/system/edgeboxctl.service + systemctl daemon-reload + @echo "Edgeboxctl installed successfully" + @echo "To start edgeboxctl run: systemctl start edgeboxctl" + +install-prod: build-prod + cp ./bin/edgeboxctl /usr/local/bin/edgeboxctl + cp ./edgeboxctl/edgeboxctl.service /lib/systemd/system/edgeboxctl.service + systemctl daemon-reload + @echo "Edgeboxctl installed successfully" + @echo "To start edgeboxctl run: systemctl start edgeboxctl" \ No newline at end of file diff --git a/edgeboxctl.service b/edgeboxctl.service new file mode 100644 index 0000000..006bb5c --- /dev/null +++ b/edgeboxctl.service @@ -0,0 +1,29 @@ +[Unit] +Description=Edgebox Control Module Service +ConditionPathExists=/home/system/ +After=network.target + +[Service] +Type=simple +User=root +Group=root +LimitNOFILE=1024 + +Restart=on-failure +RestartSec=10 +startLimitIntervalSec=60 + +WorkingDirectory=/home/system/components/edgeboxctl +ExecStart=edgeboxctl --name=edgebox-cloud + +# make sure log directory exists and owned by syslog +PermissionsStartOnly=true +ExecStartPre=/bin/mkdir -p /var/log/edgeboxctl +ExecStartPre=/bin/chown root:root /var/log/edgeboxctl +ExecStartPre=/bin/chmod 755 /var/log/edgeboxctl +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=edgeboxctl + +[Install] +WantedBy=multi-user.target