// executeOrForkPhase either directly executes the specified operation phase,
// or launches a one-shot systemd service that executes it in the background.
executeOrForkPhase either directly executes the specified operation phase,
or launches a one-shot systemd service that executes it in the background.
// executeOrForkPhase either directly executes the specified operation phase // or launches a one - shot systemd service that executes it in the background .
func executeOrForkPhase(env *localenv.LocalEnvironment, updater updater, params PhaseParams, operation ops.SiteOperation) error {
	if params.isResume() {
		if err := verifyOrDeployAgents(env); err != nil {
			log.WithError(err).Warn("Failed to verify or deploy agents.")
		}
	}
	if params.Block {
		return updater.RunPhase(context.TODO(),
			params.PhaseID,
			params.Timeout,
			params.Force)
	}
	 TODO(r0mant): Also, make sure agents are running on the cluster nodes:
	 https:github.com/gravitational/gravity/issues/1667
	if err := updater.Check(params.toFSM()); err != nil {
		return trace.Wrap(err)
	}
	commandArgs := cli.CommandArgs{
		Parser: cli.ArgsParserFunc(parseArgs),
		FlagsToAdd: []cli.Flag{
			cli.NewBoolFlag("debug", true),
			cli.NewBoolFlag("block", true),
		},
		 Avoid duplicates on command line
		FlagsToRemove: []string{"debug"},
	}
	args, err := commandArgs.Update(os.Args[1:])
	if err != nil {
		return trace.Wrap(err)
	}
	binPath, err := getBinaryPathForOperation(operation)
	if err != nil {
		return trace.Wrap(err)
	}
	env.PrintStep("Starting %v service", defaults.GravityRPCResumeServiceName)
	if err := launchOneshotService(defaults.GravityRPCResumeServiceName, binPath, args); err != nil {
		return trace.Wrap(err)
	}
	env.PrintStep(`Service %[1]v has been launched.
To monitor the operation progress:
  sudo gravity plan --operation-id=%[2]v --tail
To monitor the service logs:
  sudo journalctl -u %[1]v -f
`, defaults.GravityRPCResumeServiceName, operation.ID)
	return nil
}
func executeOrForkPhase ( env * localenv . LocalEnvironment , updater updater , params PhaseParams , operation ops . SiteOperation ) error { if params . isResume ( ) { if err := verifyOrDeployAgents ( env ) ; err != nil { log . WithError ( err ) . Warn ( " " ) } } if params . Block { return updater . RunPhase ( context . TODO ( ) , params . PhaseID , params . Timeout , params . Force ) } if err := updater . Check ( params . toFSM ( ) ) ; err != nil { return trace . Wrap ( err ) } commandArgs := cli . CommandArgs { Parser : cli . ArgsParserFunc ( parseArgs ) , FlagsToAdd : [ ] cli . Flag { cli . NewBoolFlag ( " " , true ) , cli . NewBoolFlag ( " " , true ) , } , FlagsToRemove : [ ] string { " " } , } args , err := commandArgs . Update ( os . Args [ 1 : ] ) if err != nil { return trace . Wrap ( err ) } binPath , err := getBinaryPathForOperation ( operation ) if err != nil { return trace . Wrap ( err ) } env . PrintStep ( " " , defaults . GravityRPCResumeServiceName ) if err := launchOneshotService ( defaults . GravityRPCResumeServiceName , binPath , args ) ; err != nil { return trace . Wrap ( err ) } env . PrintStep ( `Service %[1]v has been launched.

To monitor the operation progress:

  sudo gravity plan --operation-id=%[2]v --tail

To monitor the service logs:

  sudo journalctl -u %[1]v -f
` , defaults . GravityRPCResumeServiceName , operation . ID ) return nil }
executeOrForkPhase either directly executes the specified operation phase,
or launches a one-shot systemd service that executes it in the background.
executeOrForkPhase either directly executes the specified operation phase or launches a one - shot systemd service that executes it in the background .
// Continue operation in case gravity-site or etcd is down. In these // cases the agent status may not be retrievable. // If given the --block flag, we're running as a systemd unit (or a user // requested the command to execute in foreground), so proceed to perform // the command (resume or single phase) directly. // Before launching the service, perform a few prechecks, for example to // make sure that the operation is being resumed from the correct node. // // TODO(r0mant): Also, make sure agents are running on the cluster nodes: // https://github.com/gravitational/gravity/issues/1667 // Avoid duplicates on command line