added stuff to the readme and a systemd example unit master
authorMauro Scomparin <scompo@gmail.com>
Tue, 1 Sep 2020 15:43:20 +0000 (17:43 +0200)
committerMauro Scomparin <scompo@gmail.com>
Tue, 1 Sep 2020 15:43:20 +0000 (17:43 +0200)
.gitignore
README.md
server.service [new file with mode: 0644]

index 66fd13c903cac02eb9657cd53fb227823484401d..5fbaa2eb5f6b54dad37c8240f77974f989ab93b7 100644 (file)
@@ -13,3 +13,6 @@
 
 # Dependency directories (remove the comment below to include it)
 # vendor/
 
 # Dependency directories (remove the comment below to include it)
 # vendor/
+
+# the built binary
+static-server
index 831793db71cfa6a92451292416a8e01e110d4f9b..107a611b74f69ed2a22c12469e17fc783f0acad8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,2 +1,30 @@
 # static-server
 # static-server
-A static server in golang
+
+A static server in golang.
+
+## Usage
+
+To use this code you must clone and build it yourself, no binaries.
+
+### Clone
+
+    git clone git@git.scompo.it:~/repos/static-server.git
+
+### Build
+
+    cd static-server
+    go build .
+
+### Run
+
+    ./static-server
+    2020/09/01 17:41:47 static-server serving directory:  ./static  on port:  :4000
+
+## Systemd
+
+There's an example of a systemd unit called `server.service`.
+
+# Enviroinment variables
+
+- SERVER_PORT port to listen to (default `:4000`).
+- SERVER_DIR directory from where to serve (default `./static`).
diff --git a/server.service b/server.service
new file mode 100644 (file)
index 0000000..1841d42
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=static-server
+After=network.target
+
+[Service]
+Type=simple
+Restart=always
+RestartSec=1
+User=user
+Environment="SERVER_DIR=/var/lib/www"
+ExecStart=/usr/local/bin/static-server
+
+[Install]
+WantedBy=multi-user.target