97b3a1d7ea
Common is no more a thing Use of TorrentParam instead of SearchParam now Common structs for search are exported in utils/search/structs Util has been renamed utils
35 lignes
633 o
Go
35 lignes
633 o
Go
package signals
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/NyaaPantsu/nyaa/utils/log"
|
|
)
|
|
|
|
// registered interrupt callbacks.
|
|
// currently only used to gracefully close the server.
|
|
var intEvents struct {
|
|
lock sync.Mutex
|
|
funcs []func()
|
|
}
|
|
|
|
func OnInterrupt(fn func()) {
|
|
intEvents.lock.Lock()
|
|
intEvents.funcs = append(intEvents.funcs, fn)
|
|
intEvents.lock.Unlock()
|
|
}
|
|
|
|
func handleReload() {
|
|
log.Info("Got SIGHUP")
|
|
//router.ReloadTemplates()
|
|
log.Info("reloaded templates")
|
|
}
|
|
|
|
// handle interrupt signal, platform independent
|
|
func interrupted() {
|
|
intEvents.lock.Lock()
|
|
for _, fn := range intEvents.funcs {
|
|
fn()
|
|
}
|
|
intEvents.lock.Unlock()
|
|
}
|