From e6a7912b2354ec9527be28c5015335c10b7c3e40 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 29 Oct 2020 23:36:50 -0400 Subject: [PATCH] adding the daemon and some fixes --- README.org | 13 +++++++++++++ melchior-daemon.service | 14 ++++++++++++++ melchior.go | 4 +++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 melchior-daemon.service diff --git a/README.org b/README.org index ca08b75..c8815e8 100644 --- a/README.org +++ b/README.org @@ -28,3 +28,16 @@ some testing #+BEGIN_SRC socat - OPENSSL-connect:127.0.0.1:1965,verify=0 #+END_SRC + + +** Installation + +#+begin_src +go build melchior.go +cp melchior /usr/local/bin/melchior +cp melchior-daemon.service /etc/systemd/system/melchior-daemon.service +chmod 664 /etc/systemd/system/melchior-daemon.service + +sudo systemctl enable melchior-daemon +sudo systemctl start melchior-daemon +#+end_src diff --git a/melchior-daemon.service b/melchior-daemon.service new file mode 100644 index 0000000..9d62b7d --- /dev/null +++ b/melchior-daemon.service @@ -0,0 +1,14 @@ +[Unit] +Description=Melchior + +[Service] +Environment=MELCHIOR_TLS_CERT=/var/gemini/certs/jfh.me.crt +Environment=MELCHIOR_TLS_KEY=/var/gemini/certs/jfh.me.key +Environment=MELCHIOR_HOSTNAME=jfh.me +Environment=MELCHIOR_BIND_ADDR=:1965 +Environment=MELCHIOR_ROOT_DIR=/var/gemini/root/ + +ExecStart=/usr/local/bin/melchior + +[Install] +WantedBy=multi-user.target diff --git a/melchior.go b/melchior.go index 992f5c2..9925625 100644 --- a/melchior.go +++ b/melchior.go @@ -190,7 +190,9 @@ func handle(conn net.Conn) error { func reply(conn net.Conn, code int, message string) { msg := fmt.Sprintf("%d %s\r\n", code, message) _, err := conn.Write([]byte(msg)) - log.Printf("There was an error writing to the connection: %s", err) + if err != nil { + log.Printf("There was an error writing to the connection: %s", err) + } } func fullResponse(conn net.Conn, meta string, body []byte) (int, error) {