f1f9142a3c
## Description Issue described in #460 ## Changes - Edited `supervisord.conf` to exit if it detects any of the supervisored processes exiting. - minor text fix ## Notes Without this change (or something similar), if act_runner fails, then the container will stay up as a zombie container - it does nothing and does not restart. After this change, if act_runner fails (e.g. due to Gitea instance being down), then supervisord will exit and the container will be restarted. Reviewed-on: https://gitea.com/gitea/act_runner/pulls/462 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: davidfrickert <david.frickert@protonmail.com> Co-committed-by: davidfrickert <david.frickert@protonmail.com>
34 lines
626 B
Go
34 lines
626 B
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package envcheck
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/docker/docker/client"
|
|
)
|
|
|
|
func CheckIfDockerRunning(ctx context.Context, configDockerHost string) error {
|
|
opts := []client.Opt{
|
|
client.FromEnv,
|
|
}
|
|
|
|
if configDockerHost != "" {
|
|
opts = append(opts, client.WithHost(configDockerHost))
|
|
}
|
|
|
|
cli, err := client.NewClientWithOpts(opts...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer cli.Close()
|
|
|
|
_, err = cli.Ping(ctx)
|
|
if err != nil {
|
|
return fmt.Errorf("cannot ping the docker daemon, is it running? %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|