@@ -508,7 +508,51 @@ func (u *Upgrader) install(repo, name string) error {
508508 return errors .Wrap (err , "failed to list services from flist" )
509509 }
510510
511- return u .ensureRestarted (services ... )
511+ if err := u .ensureRestarted (services ... ); err != nil {
512+ return err
513+ }
514+
515+ // restarting mycelium instances on user's namespaces
516+ return u .restartMyceliumInstances ()
517+ }
518+
519+ // this method restarts all mycelium-<usernetwork> instances on user's namespaces to catch mycelium version updates
520+ func (u * Upgrader ) restartMyceliumInstances () error {
521+ const zinitPath = "/etc/zinit"
522+
523+ // Get all services from host
524+ entries , err := os .ReadDir (zinitPath )
525+ if err != nil {
526+ return fmt .Errorf ("failed to read host zinit directory: %w" , err )
527+ }
528+
529+ var myceliumServices []string
530+ for _ , entry := range entries {
531+ if entry .IsDir () || ! strings .HasSuffix (entry .Name (), ".yaml" ) || ! strings .HasPrefix (entry .Name (), "mycelium-" ) {
532+ continue
533+ }
534+
535+ serviceName := strings .TrimSuffix (entry .Name (), ".yaml" )
536+ myceliumServices = append (myceliumServices , serviceName )
537+ }
538+
539+ if len (myceliumServices ) == 0 {
540+ return nil
541+ }
542+
543+ log .Info ().Strs ("services" , myceliumServices ).Msg ("restarting mycelium instances" )
544+ if err := u .zinit .StopMultiple (20 * time .Second , myceliumServices ... ); err != nil {
545+ log .Error ().Err (err ).Msg ("failed to stop all mycelium services" )
546+ }
547+
548+ for _ , name := range myceliumServices {
549+ log .Info ().Str ("service" , name ).Msg ("starting mycelium service" )
550+ if err := u .zinit .Start (name ); err != nil {
551+ log .Error ().Err (err ).Str ("service" , name ).Msg ("could not start mycelium service" )
552+ }
553+ }
554+
555+ return nil
512556}
513557
514558func (u * Upgrader ) servicesFromStore (store meta.Walker ) ([]string , error ) {
0 commit comments