Added stderr output management to jaillover.

Added Spawn support for stderr redirection.
Added --debug option to server cmd.
Added debug information to documentation.
Finnished script logger.
This commit is contained in:
Héctor Hurtado
2020-04-20 10:18:16 +02:00
parent 63a675675a
commit 248f7d1fcc
9 changed files with 353 additions and 40 deletions
+22 -1
View File
@@ -25,6 +25,7 @@ import (
"github.com/spf13/cobra"
"github.com/BBVA/kapow/internal/logger"
"github.com/BBVA/kapow/internal/server"
)
@@ -46,6 +47,7 @@ var ServerCmd = &cobra.Command{
sConf.ClientAuth, _ = cmd.Flags().GetBool("clientauth")
sConf.ClientCaFile, _ = cmd.Flags().GetString("clientcafile")
debug, _ := cmd.Flags().GetBool("debug")
// Set environment variables KAPOW_DATA_URL and KAPOW_CONTROL_URL only if they aren't set so we don't overwrite user's preferences
if _, exist := os.LookupEnv("KAPOW_DATA_URL"); !exist {
@@ -55,6 +57,10 @@ var ServerCmd = &cobra.Command{
os.Setenv("KAPOW_CONTROL_URL", "http://"+sConf.ControlBindAddr)
}
if debug {
logger.RegisterLogger(logger.SCRIPTS, nil)
}
server.StartServer(sConf)
if len(args) > 0 {
@@ -77,7 +83,11 @@ var ServerCmd = &cobra.Command{
log.Printf("Done running powfile: %q\n", powfile)
}
select {}
if debug {
processLogs()
} else {
select {}
}
},
}
@@ -91,6 +101,8 @@ func init() {
ServerCmd.Flags().Bool("clientauth", false, "Activate client mutual tls authentication")
ServerCmd.Flags().String("clientcafile", "", "Cert file to validate client certificates")
ServerCmd.Flags().Bool("debug", false, "Activate debug mode for script executions to standard output")
}
func validateServerCommandArguments(cmd *cobra.Command, args []string) error {
@@ -111,3 +123,12 @@ func validateServerCommandArguments(cmd *cobra.Command, args []string) error {
return nil
}
func processLogs() {
for {
if !logger.ProcessMsg(logger.SCRIPTS) {
break
}
}
}