Skip to content

Commit

Permalink
modified revovery file writing and recovery method to support date and
Browse files Browse the repository at this point in the history
time stamp in the filename. This allows lots of Longbow instances to use
the recovery facility.
  • Loading branch information
jimboid committed Jun 14, 2016
1 parent 15110d6 commit 16db38e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Longbow/corelibs/scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ def monitor(jobs):
allfinished = False
interval = 0
longbowdir = os.path.expanduser('~/.Longbow')
jobfile = os.path.join(longbowdir, "jobs.recovery")
jobfile = os.path.join(longbowdir, "recovery-",
time.strftime("%Y%m%d-%H%M%S"))

LOG.info("recovery file will be placed at path '{0}'".format(jobfile))

# Find out which job has been set the highest polling frequency and use
# that.
Expand Down
25 changes: 22 additions & 3 deletions Longbow/longbow
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def main(parameters):
STAGING.cleanup(jobs)


def recover():
def recover(recoveryfile):

"""
This method is for attempting to recover a Longbow session. This should be
Expand All @@ -176,7 +176,7 @@ def recover():
LOG.info("Attempting to find the recovery files")

longbowdir = os.path.expanduser('~/.Longbow')
jobfile = os.path.join(longbowdir, "jobs.recovery")
jobfile = os.path.join(longbowdir, recoveryfile)

# Load the jobs recovery file.
if os.path.isfile(jobfile):
Expand Down Expand Up @@ -541,6 +541,25 @@ if __name__ == "__main__":

RECOVER = True

try:

POSITION = LONGBOWARGS.index("-recover")

except ValueError:

POSITION = LONGBOWARGS.index("--recover")

if (POSITION + 1 == len(LONGBOWARGS) or
LONGBOWARGS[POSITION + 1].startswith("-")):

raise EX.CommandlineargsError(
"Please specify a valid file for the --recover command line "
"parameter e.g. longbow --recover [filename] ...")

else:

RECOVERFILE = LONGBOWARGS[POSITION + 1]

# Store the VERBOSE parameter
if (LONGBOWARGS.count("-verbose") == 1 or
LONGBOWARGS.count("--verbose") == 1):
Expand Down Expand Up @@ -790,7 +809,7 @@ if __name__ == "__main__":

LOG.info("Entering recovery mode.")

recover()
recover(RECOVERFILE)

except Exception as ERR:

Expand Down

0 comments on commit 16db38e

Please sign in to comment.