Skip to content

Commit bf4be92

Browse files
committed
rephrase service file
and move RPC structure back to gossa.go
1 parent d99d975 commit bf4be92

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

gossa.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"archive/zip"
55
"compress/gzip"
6-
"context"
76
_ "embed"
87
"encoding/json"
98
"errors"
@@ -18,14 +17,17 @@ import (
1817
"net/http"
1918
"net/url"
2019
"os"
21-
"os/signal"
2220
"path/filepath"
2321
"sort"
2422
"strconv"
2523
"strings"
26-
"time"
2724
)
2825

26+
type rpcCall struct {
27+
Call string `json:"call"`
28+
Args []string `json:"args"`
29+
}
30+
2931
var rootPath = ""
3032
var handler http.Handler
3133

@@ -244,14 +246,15 @@ func main() {
244246
check(err)
245247
server := &http.Server{Addr: *host + ":" + *port, Handler: handler}
246248

247-
go func() {
248-
sigchan := make(chan os.Signal, 1)
249-
signal.Notify(sigchan, os.Interrupt)
250-
<-sigchan
251-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
252-
defer cancel()
253-
server.Shutdown(ctx)
254-
}()
249+
// clean shutdown - used only for coverage test
250+
// go func() {
251+
// sigchan := make(chan os.Signal, 1)
252+
// signal.Notify(sigchan, os.Interrupt)
253+
// <-sigchan
254+
// ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
255+
// defer cancel()
256+
// server.Shutdown(ctx)
257+
// }()
255258

256259
if !*ro {
257260
http.HandleFunc(*extraPath+"rpc", rpc)
@@ -260,6 +263,7 @@ func main() {
260263
http.HandleFunc(*extraPath+"zip", zipRPC)
261264
http.HandleFunc("/", doContent)
262265
handler = http.StripPrefix(*extraPath, http.FileServer(http.Dir(rootPath)))
266+
263267
fmt.Printf("Gossa starting on directory %s\nListening on http://%s:%s%s\n", rootPath, *host, *port, *extraPath)
264268
if err = server.ListenAndServe(); err != http.ErrServerClosed {
265269
check(err)

gossa_embed.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ type pageTemplate struct {
4141
RowsFolders []rowTemplate
4242
}
4343

44-
type rpcCall struct {
45-
Call string `json:"call"`
46-
Args []string `json:"args"`
47-
}
48-
4944
var host = flag.String("h", "127.0.0.1", "host to listen to")
5045
var port = flag.String("p", "8001", "port to listen to")
5146
var extraPath = flag.String("prefix", "/", "url prefix at which gossa can be reached, e.g. /gossa/ (slashes of importance)")

readme.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ a [simple UI](https://github.com/pldubouilh/gossa-ui) comes as default, featurin
1414
* 🔍 files/directories browser & handler
1515
* 📩 drag-and-drop uploader
1616
* 🥂 fast golang static server
17-
* 💾 90s web UI that prints in ms
18-
* 📸 picture browser
19-
* 📽️ video streaming
20-
* ✍️ simple text/note editor
17+
* 💾 90s web UI that prints in milliseconds
18+
* 📸 video streaming & picture browser
19+
* ✍️ simple note editor
2120
* ⌨️ keyboard navigation
22-
* 🚀 lightweight codebase and dependency free
21+
* 🚀 lightweight and dependency free codebase
2322
* 🔒 >95% test coverage and reproducible builds
24-
* 💑 easy/secure multi account setup, read-only mode
23+
* 💑 easy multi account setup, read-only mode
2524
* ✨ PWA enabled
2625

2726
### build

support/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use the `service` file provided here to use as a systemd service.
1111
% systemctl --user start gossa
1212

1313
# enable at boot time
14-
% systemctl --user start gossa
14+
% systemctl --user enable gossa
1515
```
1616

1717
## run with docker

support/service

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
[Unit]
22
Description=Gossa service for mytestfolder
3+
Wants=network-online.target
4+
After=network-online.target
35

46
# note: its better to use absolute paths here
57
[Service]
68
ExecStart=gossa /home/joe/mytestfolder
9+
Restart=always
10+
RestartSec=30
711

812
[Install]
913
WantedBy=multi-user.target

0 commit comments

Comments
 (0)