mirror of
https://github.com/pldubouilh/gossa
synced 2025-12-06 08:22:32 +01:00
rephrase service file
and move RPC structure back to gossa.go
This commit is contained in:
parent
d99d975f70
commit
bf4be929f5
5 changed files with 25 additions and 23 deletions
26
gossa.go
26
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)
|
||||
|
|
|
|||
|
|
@ -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)")
|
||||
|
|
|
|||
11
readme.md
11
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in a new issue