diff --git a/gossa.go b/gossa.go index f3d3cbf..350d02f 100755 --- a/gossa.go +++ b/gossa.go @@ -3,7 +3,6 @@ package main import ( "archive/zip" "compress/gzip" - "context" _ "embed" "encoding/json" "errors" @@ -18,14 +17,17 @@ import ( "net/http" "net/url" "os" - "os/signal" "path/filepath" "sort" "strconv" "strings" - "time" ) +type rpcCall struct { + Call string `json:"call"` + Args []string `json:"args"` +} + var rootPath = "" var handler http.Handler @@ -244,14 +246,15 @@ func main() { check(err) server := &http.Server{Addr: *host + ":" + *port, Handler: handler} - go func() { - sigchan := make(chan os.Signal, 1) - signal.Notify(sigchan, os.Interrupt) - <-sigchan - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - server.Shutdown(ctx) - }() + // clean shutdown - used only for coverage test + // go func() { + // sigchan := make(chan os.Signal, 1) + // signal.Notify(sigchan, os.Interrupt) + // <-sigchan + // ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + // defer cancel() + // server.Shutdown(ctx) + // }() if !*ro { http.HandleFunc(*extraPath+"rpc", rpc) @@ -260,6 +263,7 @@ func main() { http.HandleFunc(*extraPath+"zip", zipRPC) http.HandleFunc("/", doContent) handler = http.StripPrefix(*extraPath, http.FileServer(http.Dir(rootPath))) + fmt.Printf("Gossa starting on directory %s\nListening on http://%s:%s%s\n", rootPath, *host, *port, *extraPath) if err = server.ListenAndServe(); err != http.ErrServerClosed { check(err) diff --git a/gossa_embed.go b/gossa_embed.go index 2a8e78a..7171c70 100755 --- a/gossa_embed.go +++ b/gossa_embed.go @@ -41,11 +41,6 @@ type pageTemplate struct { RowsFolders []rowTemplate } -type rpcCall struct { - Call string `json:"call"` - Args []string `json:"args"` -} - var host = flag.String("h", "127.0.0.1", "host to listen to") var port = flag.String("p", "8001", "port to listen to") var extraPath = flag.String("prefix", "/", "url prefix at which gossa can be reached, e.g. /gossa/ (slashes of importance)") diff --git a/readme.md b/readme.md index cc08ba3..51f811e 100644 --- a/readme.md +++ b/readme.md @@ -14,14 +14,13 @@ a [simple UI](https://github.com/pldubouilh/gossa-ui) comes as default, featurin * 🔍 files/directories browser & handler * 📩 drag-and-drop uploader * 🥂 fast golang static server - * 💾 90s web UI that prints in ms - * 📸 picture browser - * 📽️ video streaming - * ✍️ simple text/note editor + * 💾 90s web UI that prints in milliseconds + * 📸 video streaming & picture browser + * ✍️ simple note editor * ⌨️ keyboard navigation - * 🚀 lightweight codebase and dependency free + * 🚀 lightweight and dependency free codebase * 🔒 >95% test coverage and reproducible builds - * 💑 easy/secure multi account setup, read-only mode + * 💑 easy multi account setup, read-only mode * ✨ PWA enabled ### build diff --git a/support/readme.md b/support/readme.md index 3c7d90c..9d4b083 100644 --- a/support/readme.md +++ b/support/readme.md @@ -11,7 +11,7 @@ use the `service` file provided here to use as a systemd service. % systemctl --user start gossa # enable at boot time -% systemctl --user start gossa +% systemctl --user enable gossa ``` ## run with docker diff --git a/support/service b/support/service index 2000262..c2baeaf 100644 --- a/support/service +++ b/support/service @@ -1,9 +1,13 @@ [Unit] Description=Gossa service for mytestfolder +Wants=network-online.target +After=network-online.target # note: its better to use absolute paths here [Service] ExecStart=gossa /home/joe/mytestfolder +Restart=always +RestartSec=30 [Install] WantedBy=multi-user.target \ No newline at end of file