mirror of
https://gitea.com/gitea/act_runner.git
synced 2024-12-28 11:58:20 +01:00
chore(runner): wait workflow done before shutdown the service
This commit is contained in:
parent
cbd21b8ec5
commit
d1114da299
@ -138,6 +138,9 @@ func runDaemon(ctx context.Context, envFile string) func(cmd *cobra.Command, arg
|
|||||||
})
|
})
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
|
// wait all workflows done.
|
||||||
|
poller.Wait()
|
||||||
|
// received the shutdown signal
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
log.Infoln("update runner status to offline")
|
log.Infoln("update runner status to offline")
|
||||||
_, err := cli.UpdateRunner(
|
_, err := cli.UpdateRunner(
|
||||||
|
@ -17,10 +17,7 @@ const (
|
|||||||
errorRetryTimeSleepSecs = 30
|
errorRetryTimeSleepSecs = 30
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var ErrDataLock = errors.New("Data Lock Error")
|
||||||
ErrDataLock = errors.New("Data Lock Error")
|
|
||||||
defaultLabels = []string{"self-hosted"}
|
|
||||||
)
|
|
||||||
|
|
||||||
func New(cli client.Client, dispatch func(context.Context, *runnerv1.Task) error) *Poller {
|
func New(cli client.Client, dispatch func(context.Context, *runnerv1.Task) error) *Poller {
|
||||||
return &Poller{
|
return &Poller{
|
||||||
@ -39,6 +36,10 @@ type Poller struct {
|
|||||||
errorRetryCounter int
|
errorRetryCounter int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Poller) Wait() {
|
||||||
|
p.routineGroup.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Poller) Poll(ctx context.Context, n int) error {
|
func (p *Poller) Poll(ctx context.Context, n int) error {
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
func(i int) {
|
func(i int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user