Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pidfile location and handle empty/corrupted pidfile #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions aeroo-docs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class CleanerThread(Thread):
unlink(testfile)
sleep(self.delay)

pid_file = '/tmp/aeroo-docs.pid'
pid_file = '/var/run/aeroo-docs.pid'
def start_daemon(args):
logger.info('Starting Aeroo DOCS process...')
#### Prepare spool directory
Expand All @@ -281,14 +281,18 @@ def start_daemon(args):
def stop_daemon(args):
try:
with open(pid_file, "r") as tmpfile:
pid = int(tmpfile.read())
try:
pid = int(tmpfile.read())
except ValueError:
logger.warning('Pid file is empty or corrupted! Nothing to do...')
remove(pid_file)
return None
except FileNotFoundError as e:
logger.warning('Process allready stopped. Nothing to do...')
return None
tries = 0
logger.info('Stopping Aeroo DOCS process...')
while tries < 10:
if tries == 0:
logger.info('Stopping Aeroo DOCS process...')
try:
kill(pid, SIGQUIT)
except ProcessLookupError as e:
Expand Down