Skip to content

Commit

Permalink
Attempt to restart daemon when not running
Browse files Browse the repository at this point in the history
Fixes #40
  • Loading branch information
jacebrowning committed Oct 19, 2015
1 parent 1418c2c commit b714662
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PYTHON_MAJOR ?= 3
PYTHON_MINOR ?= 4

# Test settings
UNIT_TEST_COVERAGE := 81
UNIT_TEST_COVERAGE := 80
INTEGRATION_TEST_COVERAGE := 62
COMBINED_TEST_COVERAGE := 91

Expand Down
20 changes: 17 additions & 3 deletions mine/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import time
import argparse
import subprocess

from . import CLI, VERSION, DESCRIPTION
from . import common
Expand Down Expand Up @@ -150,10 +151,23 @@ def run(path=None, cleanup=True, delay=None,
time.sleep(delay)
services.delete_conflicts(root, config_only=True, force=True)

if delay is None:
return _restart_daemon(manager)

return True


def _restart_daemon(manager):
cmd = "nohup {} --daemon --verbose >> /tmp/mine.log 2>&1 &".format(CLI)
if daemon and not manager.is_running(daemon):
msg = ("daemon is not running, start it with: " + "\n" +
"nohup %s --daemon --verbose >> /tmp/mine.log 2>&1 &")
log.warning(msg, CLI)
log.warn("daemon is not running, attempting to restart...")

log.info("$ %s", cmd)
subprocess.call(cmd, shell=True)
if manager.is_running(daemon):
return True

log.error("manually start daemon: %s", cmd)
return False

return True
Expand Down

0 comments on commit b714662

Please sign in to comment.