add runit support
[arvados.git] / services / boot / supervisor.go
1 package main
2
3 import (
4         "context"
5         "os"
6 )
7
8 type supervisor interface {
9         Running(ctx context.Context) (bool, error)
10         Start(ctx context.Context) error
11 }
12
13 func newSupervisor(ctx context.Context, name, cmd string, args ...string) supervisor {
14         if _, err := os.Stat("/run/systemd/system"); err == nil {
15                 return &systemdUnit{
16                         name: name,
17                         cmd:  cmd,
18                         args: args,
19                 }
20         }
21         return &runitService{
22                 name: name,
23                 cmd:  cmd,
24                 args: args,
25         }
26 }
27