mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-22 16:58:54 +02:00
added new file button in config editor, dockerfile fix
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -16,21 +17,27 @@ var cfg Config
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
var verifyOnly bool
|
||||
flag.BoolVar(&verifyOnly, "verify", false, "verify config without starting server")
|
||||
flag.Parse()
|
||||
args := getArgs()
|
||||
|
||||
logrus.SetFormatter(&logrus.TextFormatter{
|
||||
ForceColors: true,
|
||||
DisableColors: false,
|
||||
FullTimestamp: true,
|
||||
ForceColors: true,
|
||||
DisableColors: false,
|
||||
FullTimestamp: true,
|
||||
TimestampFormat: "01-02 15:04:05",
|
||||
})
|
||||
|
||||
if args.Command == CommandReload {
|
||||
err := utils.reloadServer()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
cfg = NewConfig(configPath)
|
||||
cfg.MustLoad()
|
||||
|
||||
if verifyOnly {
|
||||
if args.Command == CommandVerify {
|
||||
logrus.Printf("config OK")
|
||||
return
|
||||
}
|
||||
@@ -63,7 +70,7 @@ func main() {
|
||||
HTTPAddr: ":80",
|
||||
HTTPSAddr: ":443",
|
||||
Handler: http.HandlerFunc(proxyHandler),
|
||||
RedirectToHTTPS: redirectToHTTPS,
|
||||
RedirectToHTTPS: cfg.Value().RedirectToHTTPS,
|
||||
})
|
||||
panelServer = NewServer(ServerOptions{
|
||||
Name: "panel",
|
||||
@@ -71,7 +78,7 @@ func main() {
|
||||
HTTPAddr: ":8080",
|
||||
HTTPSAddr: ":8443",
|
||||
Handler: panelHandler,
|
||||
RedirectToHTTPS: redirectToHTTPS,
|
||||
RedirectToHTTPS: cfg.Value().RedirectToHTTPS,
|
||||
})
|
||||
|
||||
proxyServer.Start()
|
||||
@@ -88,10 +95,32 @@ func main() {
|
||||
signal.Notify(sig, syscall.SIGHUP)
|
||||
|
||||
<-sig
|
||||
// cfg.StopWatching()
|
||||
StopFSWatcher()
|
||||
StopDockerWatcher()
|
||||
cfg.StopProviders()
|
||||
panelServer.Stop()
|
||||
proxyServer.Stop()
|
||||
logrus.Info("shutting down")
|
||||
done := make(chan struct{}, 1)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(3)
|
||||
|
||||
go func() {
|
||||
StopFSWatcher()
|
||||
StopDockerWatcher()
|
||||
cfg.StopProviders()
|
||||
wg.Done()
|
||||
}()
|
||||
go func() {
|
||||
panelServer.Stop()
|
||||
proxyServer.Stop()
|
||||
wg.Done()
|
||||
}()
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
logrus.Info("shutdown complete")
|
||||
case <-time.After(cfg.Value().TimeoutShutdown * time.Second):
|
||||
logrus.Info("timeout waiting for shutdown")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user