Skip to content

Commit

Permalink
Ign session on watch
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Feb 14, 2022
1 parent 3f7deb9 commit b6326c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func StartWithouttSession() {
Middlewares...)
}

// StopWithouttSession 关闭服务
func StopWithouttSession(onComplete func()) {
shutdown <- true
<-shutdownComplete
gou.KillPlugins()
onComplete()
}

// Stop 关闭服务
func Stop(onComplete func()) {
shutdown <- true
Expand Down
12 changes: 6 additions & 6 deletions service/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func WatchGlobal(root string) {
fmt.Println(color.RedString("Fatal: %s", err.Error()))
return
}
Stop(func() {
StopWithouttSession(func() {
fmt.Println(color.GreenString("Service Restarted"))
go StartWithouttSession()
})
Expand Down Expand Up @@ -137,7 +137,7 @@ func WatchAPI(root string, prefix string) {

// 重启服务器
if op == "write" || op == "create" || op == "remove" || op == "rename" {
Stop(func() {
StopWithouttSession(func() {
fmt.Println(color.GreenString("Service Restarted"))
go StartWithouttSession()
})
Expand Down Expand Up @@ -268,7 +268,7 @@ func WatchTable(root string, prefix string) {

// 重启服务器
if op == "write" || op == "create" || op == "remove" || op == "rename" {
Stop(func() {
StopWithouttSession(func() {
fmt.Println(color.GreenString("Service Restarted"))
go StartWithouttSession()
})
Expand Down Expand Up @@ -335,7 +335,7 @@ func WatchChart(root string, prefix string) {

// 重启服务器
if op == "write" || op == "create" || op == "remove" || op == "rename" {
Stop(func() {
StopWithouttSession(func() {
fmt.Println(color.GreenString("Service Restarted"))
go StartWithouttSession()
})
Expand Down Expand Up @@ -402,7 +402,7 @@ func WatchPage(root string, prefix string) {

// 重启服务器
if op == "write" || op == "create" || op == "remove" || op == "rename" {
Stop(func() {
StopWithouttSession(func() {
fmt.Println(color.GreenString("Service Restarted"))
go StartWithouttSession()
})
Expand Down Expand Up @@ -450,7 +450,7 @@ func WatchWorkFlow(root string, prefix string) {

// 重启服务器
if op == "write" || op == "create" || op == "remove" || op == "rename" {
Stop(func() {
StopWithouttSession(func() {
fmt.Println(color.GreenString("Service Restarted"))
go StartWithouttSession()
})
Expand Down

0 comments on commit b6326c9

Please sign in to comment.