Skip to content
Snippets Groups Projects
Commit 45749909 authored by Ophestra's avatar Ophestra
Browse files

Merge branch 'listen-on-socket' into 'main'

feat(serve): listen on unix socket

See merge request !7
parents 7cb0a36e 2ac4ee4e
No related branches found
No related tags found
1 merge request!7feat(serve): listen on unix socket
Pipeline #969 passed
......@@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"net"
"os"
"sync/atomic"
"time"
......@@ -73,5 +74,13 @@ func serve(sig chan os.Signal, db *leveldb.DB) error {
}
}()
if conf[listen] == "unset" {
return app.Listen(conf[listenAddr])
} else {
if l, err := net.Listen("unix", conf[listen]); err != nil {
return err
} else {
return app.Listener(l)
}
}
}
......@@ -7,6 +7,7 @@ import (
const (
dbPath uint8 = iota
listen
listenAddr
allowedURL
hCaptchaSiteKey
......@@ -17,6 +18,7 @@ const (
// env variable, default pairing
var confEnv = [...][2]string{
dbPath: {"DB", "db"},
listen: {"LISTEN", "unset"},
listenAddr: {"LISTEN_ADDR", "127.0.0.1:3000"},
allowedURL: {"ALLOWED_URL", "https://hizla.io"},
hCaptchaSiteKey: {"HCAPTCHA_SITE_KEY", "unset"},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment