Skip to content

Commit

Permalink
Add option to clear lock file before running the action
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Sep 18, 2024
1 parent f354509 commit fb9bd56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lvmcryo/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ async def ln2(
show_default=False,
),
] = False,
clear_lock: Annotated[
bool,
Option(
"--clear-lock",
help="Clears the lock file if it exists before carrying out the action.",
),
] = False,
#
# Purge and fill options
#
Expand Down Expand Up @@ -490,6 +497,10 @@ async def ln2(
alerts_route=config.internal_config["api_routes"]["alerts"],
)

if LOCKFILE.exists() and clear_lock:
log.warning("Lock file exists. Removing it because --clear-lock.")
LOCKFILE.unlink()

try:
with ensure_lock(LOCKFILE):
# Run worker.
Expand Down

0 comments on commit fb9bd56

Please sign in to comment.