mirror of
https://github.com/1f349/violet.git
synced 2024-11-09 22:22:50 +00:00
Replace exit and reload logic with my new library
This commit is contained in:
parent
1ca5a6205b
commit
b84df84d51
@ -5,7 +5,6 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"github.com/1f349/violet/certs"
|
"github.com/1f349/violet/certs"
|
||||||
"github.com/1f349/violet/domains"
|
"github.com/1f349/violet/domains"
|
||||||
errorPages "github.com/1f349/violet/error-pages"
|
errorPages "github.com/1f349/violet/error-pages"
|
||||||
@ -16,16 +15,14 @@ import (
|
|||||||
"github.com/1f349/violet/servers/api"
|
"github.com/1f349/violet/servers/api"
|
||||||
"github.com/1f349/violet/servers/conf"
|
"github.com/1f349/violet/servers/conf"
|
||||||
"github.com/1f349/violet/utils"
|
"github.com/1f349/violet/utils"
|
||||||
|
"github.com/MrMelon54/exit-reload"
|
||||||
"github.com/MrMelon54/mjwt"
|
"github.com/MrMelon54/mjwt"
|
||||||
"github.com/google/subcommands"
|
"github.com/google/subcommands"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type serveCmd struct{ configPath string }
|
type serveCmd struct{ configPath string }
|
||||||
@ -157,16 +154,9 @@ func normalLoad(startUp startUpConfig, wd string) {
|
|||||||
go utils.RunBackgroundHttps("HTTPS", srvHttps)
|
go utils.RunBackgroundHttps("HTTPS", srvHttps)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for exit signal
|
exit_reload.ExitReload("Violet", func() {
|
||||||
sc := make(chan os.Signal, 1)
|
allCompilables.Compile()
|
||||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
}, func() {
|
||||||
<-sc
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
// Stop servers
|
|
||||||
log.Printf("[Violet] Stopping...")
|
|
||||||
n := time.Now()
|
|
||||||
|
|
||||||
// close http servers
|
// close http servers
|
||||||
if srvApi != nil {
|
if srvApi != nil {
|
||||||
srvApi.Close()
|
srvApi.Close()
|
||||||
@ -177,7 +167,5 @@ func normalLoad(startUp startUpConfig, wd string) {
|
|||||||
if srvHttps != nil {
|
if srvHttps != nil {
|
||||||
srvHttps.Close()
|
srvHttps.Close()
|
||||||
}
|
}
|
||||||
|
})
|
||||||
log.Printf("[Violet] Took '%s' to shutdown\n", time.Now().Sub(n))
|
|
||||||
log.Println("[Violet] Goodbye")
|
|
||||||
}
|
}
|
||||||
|
1
go.mod
1
go.mod
@ -5,6 +5,7 @@ go 1.20
|
|||||||
require (
|
require (
|
||||||
github.com/AlecAivazis/survey/v2 v2.3.7
|
github.com/AlecAivazis/survey/v2 v2.3.7
|
||||||
github.com/MrMelon54/certgen v0.0.1
|
github.com/MrMelon54/certgen v0.0.1
|
||||||
|
github.com/MrMelon54/exit-reload v0.0.1
|
||||||
github.com/MrMelon54/mjwt v0.1.1
|
github.com/MrMelon54/mjwt v0.1.1
|
||||||
github.com/MrMelon54/png2ico v1.0.1
|
github.com/MrMelon54/png2ico v1.0.1
|
||||||
github.com/MrMelon54/rescheduler v0.0.1
|
github.com/MrMelon54/rescheduler v0.0.1
|
||||||
|
2
go.sum
2
go.sum
@ -2,6 +2,8 @@ github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkk
|
|||||||
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
|
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
|
||||||
github.com/MrMelon54/certgen v0.0.1 h1:ycWdZ2RlxQ5qSuejeBVv4aXjGo5hdqqL4j4EjrXnFMk=
|
github.com/MrMelon54/certgen v0.0.1 h1:ycWdZ2RlxQ5qSuejeBVv4aXjGo5hdqqL4j4EjrXnFMk=
|
||||||
github.com/MrMelon54/certgen v0.0.1/go.mod h1:GHflVlSbtFLJZLpN1oWyUvDBRrR8qCWiwZLXCCnS2Gc=
|
github.com/MrMelon54/certgen v0.0.1/go.mod h1:GHflVlSbtFLJZLpN1oWyUvDBRrR8qCWiwZLXCCnS2Gc=
|
||||||
|
github.com/MrMelon54/exit-reload v0.0.1 h1:sxHa59tNEQMcikwuX2+93lw6Vi1+R7oCRF8a0C3alXc=
|
||||||
|
github.com/MrMelon54/exit-reload v0.0.1/go.mod h1:PLiSfmUzwdpTTQP3BBfUPhkqPwaIZjx0DuXBnM76Bug=
|
||||||
github.com/MrMelon54/mjwt v0.1.1 h1:m+aTpxbhQCrOPKHN170DQMFR5r938LkviU38unob5Jw=
|
github.com/MrMelon54/mjwt v0.1.1 h1:m+aTpxbhQCrOPKHN170DQMFR5r938LkviU38unob5Jw=
|
||||||
github.com/MrMelon54/mjwt v0.1.1/go.mod h1:oYrDBWK09Hju98xb+bRQ0wy+RuAzacxYvKYOZchR2Tk=
|
github.com/MrMelon54/mjwt v0.1.1/go.mod h1:oYrDBWK09Hju98xb+bRQ0wy+RuAzacxYvKYOZchR2Tk=
|
||||||
github.com/MrMelon54/png2ico v1.0.1 h1:zJoSSl4OkvSIMWGyGPvb8fWNa0KrUvMIjgNGLNLJhVQ=
|
github.com/MrMelon54/png2ico v1.0.1 h1:zJoSSl4OkvSIMWGyGPvb8fWNa0KrUvMIjgNGLNLJhVQ=
|
||||||
|
Loading…
Reference in New Issue
Block a user