Skip to content

Commit

Permalink
Merge pull request #2010 from ElrondNetwork/remove-start-in-epoch-func
Browse files Browse the repository at this point in the history
removed process start function when shuffled out
  • Loading branch information
LucianMincu committed Jun 25, 2020
2 parents 13d4b2c + 0aca2b5 commit 4a72f7f
Showing 1 changed file with 2 additions and 44 deletions.
46 changes: 2 additions & 44 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"math"
"math/big"
"os"
"os/exec"
"os/signal"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -1346,7 +1345,7 @@ func startNode(ctx *cli.Context, log logger.Logger, version string) error {
case <-sigs:
log.Info("terminating at user's signal...")
case sig = <-chanStopNodeProcess:
log.Info("terminating at internal stop signal", "reason", sig.Reason)
log.Info("terminating at internal stop signal", "reason", sig.Reason, "description", sig.Description)
}

chanCloseComponents := make(chan struct{})
Expand All @@ -1360,7 +1359,7 @@ func startNode(ctx *cli.Context, log logger.Logger, version string) error {
log.Warn("force closing the node", "error", "closeAllComponents did not finished on time")
}

handleAppClose(log, sig)
log.Debug("closing node")

return nil
}
Expand Down Expand Up @@ -1394,47 +1393,6 @@ func closeAllComponents(
chanCloseComponents <- struct{}{}
}

func handleAppClose(log logger.Logger, endProcessArgument endProcess.ArgEndProcess) {
log.Debug("closing node")

switch endProcessArgument.Reason {
case core.ShuffledOut:
log.Debug(
"restarting node",
"reason",
endProcessArgument.Reason,
"description",
endProcessArgument.Description,
)

newStartInEpoch(log)
default:
}
}

func newStartInEpoch(log logger.Logger) {
wd, err := os.Getwd()
if err != nil {
log.LogIfError(err)
}
nodeApp := os.Args[0]
args := os.Args
args = append(args, "-start-in-epoch")

log.Debug("startInEpoch", "working dir", wd, "nodeApp", nodeApp, "args", args)

cmd := exec.Command(nodeApp)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Args = args
cmd.Dir = wd
err = cmd.Start()
if err != nil {
log.LogIfError(err)
}
}

func createStringFromRatingsData(ratingsData *rating.RatingsData) string {
metaChainStepHandler := ratingsData.MetaChainRatingsStepHandler()
shardChainHandler := ratingsData.ShardChainRatingsStepHandler()
Expand Down

0 comments on commit 4a72f7f

Please sign in to comment.