mirror of
https://gitee.com/goploy/goploy.git
synced 2024-12-04 04:59:58 +08:00
35 lines
517 B
Go
35 lines
517 B
Go
package task
|
|
|
|
import (
|
|
"context"
|
|
"sync/atomic"
|
|
"time"
|
|
)
|
|
|
|
var counter int32
|
|
|
|
func Init() {
|
|
startMonitorTask()
|
|
startProjectTask()
|
|
startServerMonitorTask()
|
|
startDeployTask()
|
|
}
|
|
|
|
func Shutdown(ctx context.Context) error {
|
|
shutdownMonitorTask()
|
|
shutdownProjectTask()
|
|
shutdownServerMonitorTask()
|
|
shutdownDeployTask()
|
|
ticker := time.NewTicker(10 * time.Millisecond)
|
|
for {
|
|
select {
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
case <-ticker.C:
|
|
if atomic.LoadInt32(&counter) == 0 {
|
|
return nil
|
|
}
|
|
}
|
|
}
|
|
}
|