From 48701890dfb827e0cefe4f46ec7ce819edada7a7 Mon Sep 17 00:00:00 2001 From: Albert Stefanov Date: Thu, 26 Oct 2023 07:58:37 +0300 Subject: [PATCH] systemd --- README.md | 21 +++++++++++++++++++-- hall-a.env | 4 ++++ hall-b.env | 4 ++++ openfest-timer@.service | 13 +++++++++++++ start.sh | 8 -------- 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 hall-a.env create mode 100644 hall-b.env create mode 100644 openfest-timer@.service delete mode 100755 start.sh diff --git a/README.md b/README.md index b4f6f19..6c2e411 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,27 @@ -# Defcon!!! +# OpenFest Timer + +## Deployment + +Clone to `/opt/timer`. +Put `openfest-timer@.service` in `/etc/systemd/system`. +Requires NodeJS and npm. + +```bash +systemctl daemon-reload +npm install +systemctl enable --now openfest-timer@hall-a.service +systemctl enable --now openfest-timer@hall-b.service +``` + +## Based on Defcon + +### Defcon Defcon is a stopwatch running on Node.js, Express.js, and Socket.io. It is intended to be a good starting point if you're just learning to use web sockets. It currently uses xhr-polling so it is compatible with Heroku. -# Who's it for? +### Who's it for? I originally wrote Defcon over four blog posts introducing Socket.io and deploying to Heroku. Please checkout the posts on my site, [robdodson.me](http://robdodson.me) diff --git a/hall-a.env b/hall-a.env new file mode 100644 index 0000000..08e9041 --- /dev/null +++ b/hall-a.env @@ -0,0 +1,4 @@ +HOST=127.0.0.1 +PORT=5050 +TITLE=HALL-A +NODE_ENV=production diff --git a/hall-b.env b/hall-b.env new file mode 100644 index 0000000..9caccc4 --- /dev/null +++ b/hall-b.env @@ -0,0 +1,4 @@ +HOST=127.0.0.1 +PORT=5051 +TITLE=HALL-B +NODE_ENV=production diff --git a/openfest-timer@.service b/openfest-timer@.service new file mode 100644 index 0000000..df054c9 --- /dev/null +++ b/openfest-timer@.service @@ -0,0 +1,13 @@ +[Unit] +Description=OpenFest Timer (%i) +After=network.target + +[Service] +EnvironmentFile=/opt/timer/%i.env +Type=simple +Restart=on-failure +WorkingDirectory=/opt/timer +ExecStart=/usr/bin/env node app.js + +[Install] +WantedBy=multi-user.target diff --git a/start.sh b/start.sh deleted file mode 100755 index b8039ad..0000000 --- a/start.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Usage: -# HOST=127.0.0.1 PORT=5051 TITLE=HALL-B ./start.sh - -cd "$(dirname "$0")" - -NODE_ENV=production node app.js