From 8fd169bc6c43f3fa33e55480f66b24cf8c9f53b9 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sat, 28 May 2022 12:54:53 +0200 Subject: [PATCH] Dirst attempt at the daemon --- README.md | 6 ++++++ package.json | 2 +- screenshot-service.service | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 screenshot-service.service diff --git a/README.md b/README.md index 2fed8fe..8e7457d 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ BASE_URL=http://localhost:3000 docker run -i -v $PWD/static:/opt/static headles BASE_URL=http://localhost:3000 node . ``` +To set up a systemd daemon that starts with the server, use: + +``` +npm run install-daemon +``` + ## Testing the API with httpie: diff --git a/package.json b/package.json index ca6e604..f80be10 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "## Dependencies", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "install-daemon": "cp screenshot-service.service /etc/systemd/system/ && systemctl start screenshot-service && systemctl enable screenshot-service" }, "repository": { "type": "git", diff --git a/screenshot-service.service b/screenshot-service.service new file mode 100644 index 0000000..1d61f52 --- /dev/null +++ b/screenshot-service.service @@ -0,0 +1,15 @@ +[Unit] +Description=Service that takes screenshots for users of the Rentgen addon +After=network.target + +[Service] +Type=simple +User=root +Group=root +WorkingDirectory=/root/ss +ExecStart=node /root/ss +Restart=on-failure +RestartSec=1s + +[Install] +WantedBy=multi-user.target