Documentation ¶
Index ¶
- Constants
- func CmdExec(cmd *actfile.Cmd, ctx *ActRunCtx, wg *sync.WaitGroup)
- func Exec(args []string)
- func Finish()
- func StageCmdsExec(stage *actfile.ActExecStage, ctx *ActRunCtx)
- func Stop()
- type ActRunCtx
- func (ctx *ActRunCtx) Exec()
- func (ctx *ActRunCtx) ExecBeforeAll()
- func (ctx *ActRunCtx) FinalStageExec()
- func (ctx *ActRunCtx) GetLocalVars() map[string]string
- func (ctx *ActRunCtx) MergeVars() map[string]string
- func (ctx *ActRunCtx) Print()
- func (ctx *ActRunCtx) Stack() []*ActRunCtx
- func (ctx *ActRunCtx) VarsToEnvVars(vars map[string]string) []string
- type Info
- func (info *Info) AddChildActId(id string)
- func (info *Info) AddCmdPgid(pgid int)
- func (info *Info) GetDataDirPath() string
- func (info *Info) GetEnvVarsFilePath() string
- func (info *Info) GetLogFilePath() string
- func (info *Info) GetNameIdOrId() string
- func (info *Info) Kill()
- func (info *Info) KillChildActs()
- func (info *Info) KillChildCmds()
- func (info *Info) KillChildren()
- func (info *Info) RmChildActId(id string)
- func (info *Info) RmCmdPgid(pgid int)
- func (info *Info) RmDataDir()
- func (info *Info) Save()
- func (info *Info) SetIsKilling()
- type LogWriter
- type RunCtx
Constants ¶
View Source
const ( ExecStateStopped string = "stopped" ExecStateRunning = "running" )
############################################################ Types ############################################################ *
- Execution state.
View Source
const ActCallIdSeparator = "."
*
- In s subact chain we separate each act name by this separator
- like when we run `act run foo.bar`. In this case `bar` is a
- subact of the act `foo` and the whole act is uniquely identified
- by the name `foo.bar`.
View Source
const ActDataDirName = ".actdt"
*
- This is the name of the directory where we going to hold
- all info for running acts.
View Source
const EnvFileName = "env"
*
- This is the name of dotenv var file we use to share variables
- between act/command execution.
View Source
const InfoFileName = "info.json"
*
- This is the file name we going to use when saving the info
- struct back to file system.
Variables ¶
This section is empty.
Functions ¶
func Exec ¶
func Exec(args []string)
############################################################ Exported Functions ############################################################ *
- This function to execute run command.
func Finish ¶ added in v1.4.0
func Finish()
*
- This function going to cleanup everything for this command on exit.
func StageCmdsExec ¶ added in v1.3.0
func StageCmdsExec(stage *actfile.ActExecStage, ctx *ActRunCtx)
*
- This function going to execute a stage.
Types ¶
type ActRunCtx ¶
type ActRunCtx struct { /** * Reference to global run context. */ RunCtx *RunCtx /** * Actfile where we found this act. */ ActFile *actfile.ActFile /** * The act to run. */ Act *actfile.Act /** * Prev context in the chain. */ PrevCtx *ActRunCtx /** * This is the call id for the act. */ CallId string /** * Indicates which stage is currently running. */ CurrentStage *actfile.ActExecStage /** * List of cli flag values passed by the user. */ FlagVals map[string]string /** * Cli arguments after extracting flags. */ Args []string /** * Set of variables passed from parent acts. */ ParentVars map[string]string /** * Act runtime vars. */ ActVars map[string]string /** * Set of variables scoped to act execution. */ Vars map[string]string }
*
- This is the context to run an act.
func FindActCtx ¶
func FindActCtx( actNames []string, actFile *actfile.ActFile, prevCtx *ActRunCtx, runCtx *RunCtx, ) (*ActRunCtx, error)
*
- This function going to find an act to run based on the call id
- user provided.
func (*ActRunCtx) ExecBeforeAll ¶
func (ctx *ActRunCtx) ExecBeforeAll()
*
- This function going to run all before acts not already
- executed for the whole act run context chain.
func (*ActRunCtx) FinalStageExec ¶ added in v1.4.0
func (ctx *ActRunCtx) FinalStageExec()
*
- This function going to run teardown commands of currently
- running act upon exit. *
- @TODO: We need to run teardown cmds of all running acts.
func (*ActRunCtx) Print ¶
func (ctx *ActRunCtx) Print()
*
- This is an utilitary function that going to print the content
- of this act run context. We get the whole act run context stack
- so we can print the whole chain from the first one.
func (*ActRunCtx) Stack ¶
*
- This function going to get the whole act run context stack
- starting from this act run context. Act contexts are linked
- together (linked list) but it could happen that multiple
- act run context has the same previous context in this liked
- list (this happen when we run commands in parallel that call
- other acts). This way is useful to be able to get the whole
- stack of act contexts starting from any node in this linked
- list (for printing for example).
type Info ¶
type Info struct { /** * Which running act going to receive an unique short hash * id which going to be used to name the data folder for * this act in the act data dir. */ Id string /** * If this act was created from another act process then we * going to store parent act id here. We do this because we * need to update parent when the state of this act change. */ ParentActId string /** * Name is a human friendly id assigned by the user when * running the act. User can then use this name to stop * o get logs for the act. */ NameId string /** * This is the process group id of this act process. */ Pgid int /** * This is the process id. */ Pid int /** * This is the list of all command process group ids created * by this act process. When we are running a sync act then * at any given time this array going to have one and only one * pgid (the pgid of currently running command). When running a * parallel act then usually this array going to contain the * pgids of all commands running in parallel. */ CmdPgids []int /** * This is a list of ids of all act detached processes created * by this act process. */ ChildActIds []string /** * Flag to indicate we are killing the process. */ IsKilling bool // contains filtered or unexported fields }
*
- This struct going to hold run context info that going to
- be stored to a file describing a running act.
func GetInfoCallStack ¶
############################################################ Exported Functions ############################################################ *
- This function get call stack from an act id.
func (*Info) AddChildActId ¶
############################################################ Info Struct Functions ############################################################ *
- This function going to add a new child act run id to info
- and then save info back to file system.
func (*Info) AddCmdPgid ¶
*
- This function going to add a new Pgid to info and then save
- info back to file system.
func (*Info) Kill ¶
func (info *Info) Kill()
*
- This function going to quit a running process associated
- with this specific info.
func (*Info) KillChildActs ¶ added in v1.4.0
func (info *Info) KillChildActs()
*
- This function going to kill only the running child detached acts.
func (*Info) KillChildCmds ¶ added in v1.4.0
func (info *Info) KillChildCmds()
*
- This function going to kill only the running child commands.
func (*Info) KillChildren ¶ added in v1.4.0
func (info *Info) KillChildren()
*
- This function going to kill all children processes associated
- with this info.
func (*Info) RmChildActId ¶
*
- This function removes a child act run id from info and
- then save the info back to file system.
func (*Info) RmCmdPgid ¶
*
- This function removes a pgid from info and then save the info
- back to file system.
func (*Info) RmDataDir ¶
func (info *Info) RmDataDir()
*
- This function going to remove run info directory.
func (*Info) Save ¶
func (info *Info) Save()
*
- This function going to save info to a file in the data
- directory.
func (*Info) SetIsKilling ¶
func (info *Info) SetIsKilling()
*
- This function going to set IsKilling flag.
type LogWriter ¶
*
- This is the main struct which implements io.Writer interface
- to be used as stdout/stderr for commands.
type RunCtx ¶
type RunCtx struct { /** * Cli arguments passed by the user. */ Args []string /** * This is the act ctx we going to execute. */ ActCtx *ActRunCtx /** * This is the root actfile. */ ActFile *actfile.ActFile /** * This is a set indicating which actfiles were already loaded. */ LoadedActFiles map[string]bool /** * This are global variables to be used by all acts in the stack. */ Vars map[string]string /** * Set of variables loaded from file. */ EnvFileVars map[string]string /** * Act runtime variables. */ ActVars map[string]string /** * This stack going to hold all acts run contexts we have * active so far. */ ActCtxCallStack []*ActRunCtx /** * Run context info as stored in act data dir. */ Info *Info /** * Flag indicating if we are running the process as a * daemon in the background. */ IsDaemon bool /** * Flag indicating the state of the execution. */ State string /** * Flag indicating we are finishing the execution. */ IsFinishing bool /** * Log mode. */ Log string /** * Flag indicating we should supress all logs. */ Quiet bool }
*
- This run context going to hold all global info we need to run
- an act.
Click to show internal directories.
Click to hide internal directories.