Skip to content

Commit

Permalink
we can never pass more than our App ID to our Extra functions
Browse files Browse the repository at this point in the history
we're ALWAYS going to be in a lock when these functions are called, there is no reason to ever unlock and call them either
  • Loading branch information
sabey committed Jul 26, 2018
1 parent 455e85d commit b71babc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,12 @@ EnvParent bool `json:"env-parent,omitempty"`

// ExtraArgs is an optional set of values that will be appended to Args.
ExtraArgs func(
app *App,
id string,
) []string `json:"-"`

// ExtraEnv is an optional set of values that will be appended to Env.
ExtraEnv func(
app *App,
id string,
) []string `json:"-"`

// Stdin specifies the process's standard input.
Expand Down Expand Up @@ -393,7 +393,7 @@ StdMerge bool `json:"std-merge,omitempty"`
// new process. It does not include standard input, standard output, or
// standard error. If non-nil, entry i becomes file descriptor 3+i.
ExtraFiles func(
app *App,
id string,
) []*os.File `json:"-"`

// TriggerStart is called from tick in runApps() before we attempt to execute an App.
Expand Down
6 changes: 3 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func (self *App) startApp() error {
cmd.Args = append(cmd.Args, self.config.Args...)
}
if self.config.ExtraArgs != nil {
if a := self.config.ExtraArgs(self); len(a) > 0 {
if a := self.config.ExtraArgs(self.id); len(a) > 0 {
cmd.Args = append(cmd.Args, a...)
}
}
Expand All @@ -340,7 +340,7 @@ func (self *App) startApp() error {
cmd.Env = append(cmd.Env, self.config.Env...)
}
if self.config.ExtraEnv != nil {
if e := self.config.ExtraEnv(self); len(e) > 0 {
if e := self.config.ExtraEnv(self.id); len(e) > 0 {
cmd.Env = append(cmd.Env, e...)
}
}
Expand Down Expand Up @@ -455,7 +455,7 @@ func (self *App) startApp() error {
}
// extra files
if self.config.ExtraFiles != nil {
if e := self.config.ExtraFiles(self); len(e) > 0 {
if e := self.config.ExtraFiles(self.id); len(e) > 0 {
cmd.ExtraFiles = e
}
}
Expand Down
6 changes: 3 additions & 3 deletions config_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ type ConfigApp struct {
//
// ExtraArgs is an optional set of values that will be appended to Args.
ExtraArgs func(
app *App,
id string,
) []string `json:"-"`
// ExtraEnv is an optional set of values that will be appended to Env.
ExtraEnv func(
app *App,
id string,
) []string `json:"-"`
// Stdin specifies the process's standard input.
//
Expand Down Expand Up @@ -145,7 +145,7 @@ type ConfigApp struct {
// new process. It does not include standard input, standard output, or
// standard error. If non-nil, entry i becomes file descriptor 3+i.
ExtraFiles func(
app *App,
id string,
) []*os.File `json:"-"`
// TriggerStart is called from tick in runApps() before we attempt to execute an App.
TriggerStart func(
Expand Down
9 changes: 5 additions & 4 deletions unittest/testserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,26 @@ func main() {
a.WorkingDirectory = filepath.Clean(wd + "/../" + a.WorkingDirectory)
// add env
a.Env = append(a.Env, fmt.Sprintf("%s=%s", patrol.PATROL_ENV_UNITTEST_KEY, patrol.PATROL_ENV_UNITTEST_VALUE))
// triggers
// extra - NOOP
a.ExtraArgs = func(
app *patrol.App,
id string,
) []string {
// do nothing
return nil
}
a.ExtraEnv = func(
app *patrol.App,
id string,
) []string {
// do nothing
return nil
}
a.ExtraFiles = func(
app *patrol.App,
id string,
) []*os.File {
// do nothing
return nil
}
// triggers
a.TriggerStart = func(
app *patrol.App,
) {
Expand Down

0 comments on commit b71babc

Please sign in to comment.