Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Exit code fix for --no-watcher and ON_CHANGE="" (#43)
Browse files Browse the repository at this point in the history
* temporary key change

* reverted key

* vendor changes

* space in .travis.yml file

* remove unused function

* fix issue with ordering of filters

* added comment and fixed logging statement

* removed println

* updated Readme to notify users of changes

* known issues added

* known issues added typo fixed

* no watcher scneario and no on change return exit code

* merge #2
  • Loading branch information
kewegner authored and kylegc committed Oct 10, 2019
1 parent 74154c4 commit ca74aa9
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func runWatcher(fileChangeCommand string, dirs []string, killServer bool) error
ControllerDebug.log("About to perform the ON_CHANGE action.")

if fileChangeCommand != "" {
go runCommands(fileChangeCommand, fileWatcher, killServer)
go runCommands(fileChangeCommand, fileWatcher, killServer, false)
}

case err := <-w.Error:
Expand Down Expand Up @@ -469,7 +469,7 @@ func runWatcher(fileChangeCommand string, dirs []string, killServer bool) error
determine if we need to kill the server process
*/
func runCommands(commandString string, theProcessType ProcessType, killServer bool) {
func runCommands(commandString string, theProcessType ProcessType, killServer bool, noWatcher bool) {

var cmd *exec.Cmd
var err error
Expand Down Expand Up @@ -502,9 +502,24 @@ func runCommands(commandString string, theProcessType ProcessType, killServer bo
mutexUnlocked = true

err = waitProcess(cmd, theProcessType)
if noWatcher {
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {

if err != nil {
ControllerInfo.log("Wait received error on APPSODY_RUN/DEBUG/TEST ", err)
statusCode := exitErr.ExitCode()
ControllerError.log("Wait received error with status code: " + strconv.Itoa(statusCode) + " due to error: " + err.Error())
os.Exit(statusCode)
// The program has exited with an exit code != 0

} else {
ControllerError.log("Could not determine exit code for error: ", err)
os.Exit(1)
}
}
} else {
if err != nil {
ControllerInfo.log("Wait received error on APPSODY_RUN/DEBUG/TEST ", err)
}
}
} else {
ControllerDebug.log("Inside the ON_CHANGE path")
Expand Down Expand Up @@ -674,11 +689,11 @@ func main() {
if fileChangeCommand == "" || disableWatcher {
ControllerDebug.log("The fileChangeCommand environment variable APPSODY_RUN/DEBUG/TEST_ON_CHANGE is unspecified or file watching was disabled by the CLI.")
ControllerDebug.log("Running APPSODY_RUN,APPSODY_DEBUG or APPSODY_TEST sync: " + startCommand)
runCommands(startCommand, server, false)
runCommands(startCommand, server, false, true)
} else {
ControllerDebug.log("Running APPSODY_RUN,APPSODY_DEBUG or APPSODY_TEST async: " + startCommand)

go runCommands(startCommand, server, false)
go runCommands(startCommand, server, false, false)
}
if fileChangeCommand != "" && !disableWatcher {

Expand Down

0 comments on commit ca74aa9

Please sign in to comment.