all: sync with master; upd chlog

This commit is contained in:
Ainar Garipov
2023-09-07 17:13:48 +03:00
parent 3be7676970
commit 7b93f5d7cf
306 changed files with 19770 additions and 4916 deletions

View File

@@ -34,6 +34,7 @@ const (
type program struct {
clientBuildFS fs.FS
signals chan os.Signal
done chan struct{}
opts options
}
@@ -46,19 +47,19 @@ func (p *program) Start(_ service.Service) (err error) {
args := p.opts
args.runningAsService = true
go run(args, p.clientBuildFS)
go run(args, p.clientBuildFS, p.done)
return nil
}
// Stop implements service.Interface interface for *program.
func (p *program) Stop(_ service.Service) (err error) {
select {
case p.signals <- syscall.SIGINT:
// Go on.
default:
// Stop should not block.
}
log.Info("service: stopping: waiting for cleanup")
aghos.SendShutdownSignal(p.signals)
// Wait for other goroutines to complete their job.
<-p.done
return nil
}
@@ -198,7 +199,12 @@ func restartService() (err error) {
// - run: This is a special command that is not supposed to be used directly
// it is specified when we register a service, and it indicates to the app
// that it is being run as a service/daemon.
func handleServiceControlAction(opts options, clientBuildFS fs.FS, signals chan os.Signal) {
func handleServiceControlAction(
opts options,
clientBuildFS fs.FS,
signals chan os.Signal,
done chan struct{},
) {
// Call chooseSystem explicitly to introduce OpenBSD support for service
// package. It's a noop for other GOOS values.
chooseSystem()
@@ -233,6 +239,7 @@ func handleServiceControlAction(opts options, clientBuildFS fs.FS, signals chan
s, err := service.New(&program{
clientBuildFS: clientBuildFS,
signals: signals,
done: done,
opts: runOpts,
}, svcConfig)
if err != nil {