Skip to content

Commit

Permalink
Change the sense of the flag, pass it into the existing variable to u…
Browse files Browse the repository at this point in the history
…se stdin or not
  • Loading branch information
PaulSnow committed Aug 9, 2017
1 parent 8fcdbf3 commit a0cafb4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
7 changes: 3 additions & 4 deletions engine/NetStart.go
Expand Up @@ -493,10 +493,9 @@ func NetStart(s *state.State, p *FactomParams, listenToStdin bool) {
RegisterPrometheus()

go controlPanel.ServeControlPanel(fnodes[0].State.ControlPanelChannel, fnodes[0].State, connectionMetricsChannel, p2pNetwork, Build)
// Listen for commands:
if !p.disableSimControl {
SimControl(p.ListenTo, listenToStdin)
}

SimControl(p.ListenTo, listenToStdin)

}

//**********************************************************************
Expand Down
6 changes: 3 additions & 3 deletions engine/factomParams.go
Expand Up @@ -53,7 +53,7 @@ type FactomParams struct {
pluginPath string
torManage bool
torUpload bool
disableSimControl bool
Sim_Stdin bool
exposeProfiling bool
}

Expand Down Expand Up @@ -109,7 +109,7 @@ func ParseCmdLine(args []string) *FactomParams {

superVerboseMessages := flag.Bool("svm", false, "If true, print out every single message as you receive it.")

disableSimControlPtr := flag.Bool("nosim", false, "Using this flag disables sim control")
sim_stdinPtr := flag.Bool("sim_stdin", true, "If true, sim control reads from stdin.")

// Plugins
pluginPath := flag.String("plugin", "", "Input the path to any plugin binaries")
Expand Down Expand Up @@ -161,7 +161,7 @@ func ParseCmdLine(args []string) *FactomParams {
p.fastLocation = *fastLocationPtr
p.loglvl = *logLvlPtr
p.logjson = *logJsonPtr
p.disableSimControl = *disableSimControlPtr
p.Sim_Stdin = *sim_stdinPtr
p.exposeProfiling = *exposeProfilePtr

p.svm = *superVerboseMessages
Expand Down
6 changes: 3 additions & 3 deletions engine/simControl.go
Expand Up @@ -42,13 +42,13 @@ var InputChan = make(chan string) // Get commands here
func GetLine(listenToStdin bool) string {

if listenToStdin {
l := make([]byte, 100)
line := make([]byte, 100)
var err error
// When running as a detatched process, this routine becomes a very tight loop and starves other goroutines.
// So, we will sleep before letting it check to see if Stdin has been reconnected
for {
if _, err = os.Stdin.Read(l); err == nil {
return string(l)
if _, err = os.Stdin.Read(line); err == nil {
return string(line)
} else {
if err == io.EOF {
fmt.Printf("Error reading from std, sleeping for 5s: %s\n", err.Error())
Expand Down
3 changes: 2 additions & 1 deletion factomd.go
Expand Up @@ -15,7 +15,8 @@ import (
func main() {
// uncomment StartProfiler() to run the pprof tool (for testing)
params := engine.ParseCmdLine(os.Args[1:])
state := engine.Factomd(params, true)
sim_Stdin := params.Sim_Stdin
state := engine.Factomd(params, sim_Stdin)
for state.Running() {
time.Sleep(time.Second)
}
Expand Down

0 comments on commit a0cafb4

Please sign in to comment.