1
0
Fork 0
Philip O'Toole 8 months ago
parent 76dfa7cdea
commit 6c19733b15

@ -8,7 +8,6 @@ import (
"log" "log"
"net" "net"
"os" "os"
"os/signal"
"runtime" "runtime"
"strings" "strings"
"syscall" "syscall"
@ -57,6 +56,9 @@ func init() {
} }
func main() { func main() {
// Handle signals first, so signal handling is established before anything else.
sigCh := HandleSignals(syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
cfg, err := ParseFlags(name, desc, &BuildInfo{ cfg, err := ParseFlags(name, desc, &BuildInfo{
Version: cmd.Version, Version: cmd.Version,
Commit: cmd.Commit, Commit: cmd.Commit,
@ -199,10 +201,7 @@ func main() {
} }
// Block until signalled. // Block until signalled.
terminate := make(chan os.Signal, 1) <-sigCh
signal.Notify(terminate, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
sig := <-terminate
log.Printf(`received signal "%s", shutting down`, sig.String())
// Stop the HTTP server first, so clients get notification as soon as // Stop the HTTP server first, so clients get notification as soon as
// possible that the node is going away. // possible that the node is going away.

@ -113,6 +113,9 @@ class TestBootstrappingRestartLeaveOnRemove(unittest.TestCase):
self.assertEqual(n0.wait_for_leader(), n1.wait_for_leader()) self.assertEqual(n0.wait_for_leader(), n1.wait_for_leader())
self.assertEqual(n0.wait_for_leader(), n2.wait_for_leader()) self.assertEqual(n0.wait_for_leader(), n2.wait_for_leader())
self.assertEqual(len(n0.nodes()), 3)
self.assertEqual(len(n1.nodes()), 3)
self.assertEqual(len(n2.nodes()), 3)
# Restart one node, and ensure it still forms a cluster using the same launch params, # Restart one node, and ensure it still forms a cluster using the same launch params,
# even though it was removed from the cluster on shutdown. # even though it was removed from the cluster on shutdown.

@ -166,7 +166,7 @@ class Node(object):
if self.raft_adv is None: if self.raft_adv is None:
self.raft_adv = self.raft_addr self.raft_adv = self.raft_addr
def start(self, join=None, join_attempts=None, join_interval=None, join_as=None, def start(self, join=None, join_attempts=None, join_interval="1s", join_as=None,
disco_mode=None, disco_key=None, disco_config=None, wait=True, timeout=TIMEOUT): disco_mode=None, disco_key=None, disco_config=None, wait=True, timeout=TIMEOUT):
if self.process is not None: if self.process is not None:
return return
@ -231,6 +231,8 @@ class Node(object):
time.sleep(0.1) time.sleep(0.1)
else: else:
break break
with open(os.path.join(self.dir, "pid"), "w") as f:
f.write(str(self.process.pid))
return self return self
def stop(self, graceful=False): def stop(self, graceful=False):

Loading…
Cancel
Save