mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
shutdown your background workers!
I believe everything #74 was caused by not shutting down the userDaemon when we do a pseudo-restart. shutdown of it and the invite daemon are now deferred so this should fix any problems and reduce log spam.
This commit is contained in:
parent
e6e5231f63
commit
47ac505cac
6
main.go
6
main.go
@ -576,11 +576,13 @@ func start(asDaemon, firstCall bool) {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
inviteDaemon := newInviteDaemon(time.Duration(60*time.Second), app)
|
invDaemon := newInviteDaemon(time.Duration(60*time.Second), app)
|
||||||
go inviteDaemon.run()
|
go invDaemon.run()
|
||||||
|
defer invDaemon.shutdown()
|
||||||
|
|
||||||
userDaemon := newUserDaemon(time.Duration(60*time.Second), app)
|
userDaemon := newUserDaemon(time.Duration(60*time.Second), app)
|
||||||
go userDaemon.run()
|
go userDaemon.run()
|
||||||
|
defer userDaemon.shutdown()
|
||||||
|
|
||||||
if app.config.Section("password_resets").Key("enabled").MustBool(false) && serverType == mediabrowser.JellyfinServer {
|
if app.config.Section("password_resets").Key("enabled").MustBool(false) && serverType == mediabrowser.JellyfinServer {
|
||||||
go app.StartPWR()
|
go app.StartPWR()
|
||||||
|
@ -42,6 +42,13 @@ func (rt *userDaemon) run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rt *userDaemon) shutdown() {
|
||||||
|
rt.Stopped = true
|
||||||
|
rt.ShutdownChannel <- "Down"
|
||||||
|
<-rt.ShutdownChannel
|
||||||
|
close(rt.ShutdownChannel)
|
||||||
|
}
|
||||||
|
|
||||||
func (app *appContext) checkUsers() {
|
func (app *appContext) checkUsers() {
|
||||||
if err := app.storage.loadUsers(); err != nil {
|
if err := app.storage.loadUsers(); err != nil {
|
||||||
app.err.Printf("Failed to load user expiries: %v", err)
|
app.err.Printf("Failed to load user expiries: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user