mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 08:48:32 +02:00
simplify task package implementation
This commit is contained in:
@@ -32,10 +32,10 @@ func setup() {
|
||||
return
|
||||
}
|
||||
|
||||
task := task.GlobalTask("error page")
|
||||
dirWatcher = W.NewDirectoryWatcher(task.Subtask("dir watcher"), errPagesBasePath)
|
||||
t := task.RootTask("error_page", true)
|
||||
dirWatcher = W.NewDirectoryWatcher(t, errPagesBasePath)
|
||||
loadContent()
|
||||
go watchDir(task)
|
||||
go watchDir()
|
||||
}
|
||||
|
||||
func GetStaticFile(filename string) ([]byte, bool) {
|
||||
@@ -73,11 +73,11 @@ func loadContent() {
|
||||
}
|
||||
}
|
||||
|
||||
func watchDir(task *task.Task) {
|
||||
eventCh, errCh := dirWatcher.Events(task.Context())
|
||||
func watchDir() {
|
||||
eventCh, errCh := dirWatcher.Events(task.RootContext())
|
||||
for {
|
||||
select {
|
||||
case <-task.Context().Done():
|
||||
case <-task.RootContextCanceled():
|
||||
return
|
||||
case event, ok := <-eventCh:
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user