convert systemd unit to Type=notify and report readiness

This commit is contained in:
Pavel Sviderski
2024-09-20 23:11:00 +10:00
parent ea8dfca14c
commit 73be824f30
5 changed files with 35 additions and 6 deletions
+9
View File
@@ -37,6 +37,8 @@ type Machine struct {
config Config
state *State
// started is closed when the machine is ready to serve requests on the local API server.
started chan struct{}
// initialised is signalled when the machine is configured as a member of a cluster.
initialised chan struct{}
@@ -90,6 +92,7 @@ func NewMachine(config *Config) (*Machine, error) {
m := &Machine{
config: *config,
state: state,
started: make(chan struct{}),
initialised: make(chan struct{}, 1),
cluster: c,
newMachinesCh: c.WatchNewMachines(),
@@ -110,6 +113,11 @@ func newGRPCServer(m pb.MachineServer, c pb.ClusterServer) *grpc.Server {
return s
}
// Started returns a channel that is closed when the machine is ready to serve requests on the local API server.
func (m *Machine) Started() <-chan struct{} {
return m.started
}
// IsInitialised returns true if the machine has been configured as a member of a cluster,
// either by initialising a new cluster on it or joining an existing one.
func (m *Machine) IsInitialised() bool {
@@ -141,6 +149,7 @@ func (m *Machine) Run(ctx context.Context) error {
return nil
},
)
close(m.started)
// Control loop for managing the network controller.
errGroup.Go(