// launchOneshotService launches the specified command as a one-shot systemd
// service with the specified name.
launchOneshotService launches the specified command as a one-shot systemd
service with the specified name.
// launchOneshotService launches the specified command as a one - shot systemd // service with the specified name .
func launchOneshotService(name, binPath string, args []string) error {
	systemd, err := systemservice.New()
	if err != nil {
		return trace.Wrap(err)
	}
	status, err := systemd.StatusService(name)
	if err != nil {
		return trace.Wrap(err)
	}
	switch status {
	case systemservice.ServiceStatusActivating, systemservice.ServiceStatusActive:
		return trace.AlreadyExists("service %v is already running", name)
	}
	return service.ReinstallOneshot(systemservice.NewServiceRequest{
		Name:    name,
		NoBlock: true,
		ServiceSpec: systemservice.ServiceSpec{
			User:         constants.RootUIDString,
			StartCommand: strings.Join(append([]string{binPath}, args...), " "),
		},
	})
}
func launchOneshotService ( name , binPath string , args [ ] string ) error { systemd , err := systemservice . New ( ) if err != nil { return trace . Wrap ( err ) } status , err := systemd . StatusService ( name ) if err != nil { return trace . Wrap ( err ) } switch status { case systemservice . ServiceStatusActivating , systemservice . ServiceStatusActive : return trace . AlreadyExists ( " " , name ) } return service . ReinstallOneshot ( systemservice . NewServiceRequest { Name : name , NoBlock : true , ServiceSpec : systemservice . ServiceSpec { User : constants . RootUIDString , StartCommand : strings . Join ( append ( [ ] string { binPath } , args ... ) , " " ) , } , } ) }
launchOneshotService launches the specified command as a one-shot systemd
service with the specified name.
launchOneshotService launches the specified command as a one - shot systemd service with the specified name .
// See if the service is already running. // Since we're using a one-shot service, it will be in "activating" state // for the duration of the command execution. In fact, one-shot services // never reach "active" state, but we're checking it too just in case.