From: Mauro Scomparin Date: Tue, 1 Sep 2020 15:43:20 +0000 (+0200) Subject: added stuff to the readme and a systemd example unit X-Git-Url: https://git.scompo.it/?a=commitdiff_plain;h=9d55bd34067bad4943e3f7ed48f2d62f8deb405e;p=static-server.git added stuff to the readme and a systemd example unit --- diff --git a/.gitignore b/.gitignore index 66fd13c..5fbaa2e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +# the built binary +static-server diff --git a/README.md b/README.md index 831793d..107a611 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ # 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 index 0000000..1841d42 --- /dev/null +++ b/server.service @@ -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