Now the supervisor does its first real work. Starting a service spawns its command through the runtime and moves it into the Starting state, remembering the handle so it can signal that process later. Today you wire the supervisor to the runtime.
Start a Stopped service - spawn its command via the runtime and move it to Starting.
Starting a service is two things happening together: a process is spawned and
the service’s state advances. The supervisor asks its runtime to Start the
service’s command, and the runtime hands back a Handle - the token the supervisor
will later use to signal or identify that exact process. The service stashes that
handle, because when it is time to stop or reap this service, the supervisor must
know which process is its own.
Notice the state goes to Starting, not straight to Running. Spawning a process
and that process being ready to serve are different moments - a database has to
open its files, a web server has to bind its port. Modelling that gap is what lets a
dependent service wait for its dependency to be genuinely ready later. For now,
Starting means “we have launched it; readiness is the next lesson.”
// Service gains a Handle field; Supervisor holds the runtimefunc (s *Supervisor) Start(name string) {svc, _ := s.Get(name)svc.Handle = s.rt.Start(svc.Command) // spawn via the runtimesvc.State = Starting // Stopped -> Starting}// a plain start for now; making it safe to call twice is a later lesson