Browse Source

Add the command line parameter —pidfile to set an explicit PID-file name.

pull/175/head
shypike 12 years ago
parent
commit
c535fecf7f
  1. 14
      SABnzbd.py
  2. 9
      sabnzbd/__init__.py

14
SABnzbd.py

@ -264,7 +264,8 @@ def print_help():
print " -d --daemon Use when run as a service"
else:
print " -d --daemon Fork daemon process"
print " --pid <path> Create a PID file in the listed folder (full path)"
print " --pid <path> Create a PID file in the given folder (full path)"
print " --pidfile <path> Create a PID file with the given name (full path)"
print
print " --force Discard web-port timeout (see Wiki!)"
print " -h --help Print this message"
@ -839,7 +840,7 @@ def commandline_handler(frozen=True):
'weblogging=', 'server=', 'templates', 'no_ipv6',
'template2', 'browser=', 'config-file=', 'force',
'version', 'https=', 'autorestarted', 'repair', 'repair-all',
'log-all', 'no-login', 'pid=', 'new', 'sessions', 'console',
'log-all', 'no-login', 'pid=', 'new', 'sessions', 'console', 'pidfile=',
# Below Win32 Service options
'password=', 'username=', 'startup=', 'perfmonini=', 'perfmondll=',
'interactive', 'wait=',
@ -931,6 +932,7 @@ def main():
no_login = False
re_argv = [sys.argv[0]]
pid_path = None
pid_file = None
new_instance = False
force_sessions = False
osx_console = False
@ -1013,6 +1015,10 @@ def main():
pid_path = arg
re_argv.append(opt)
re_argv.append(arg)
elif opt in ('--pidfile',):
pid_file = arg
re_argv.append(opt)
re_argv.append(arg)
elif opt in ('--new',):
new_instance = True
elif opt in ('--sessions',):
@ -1579,8 +1585,8 @@ def main():
# Write URL directly to registry
set_connection_info(api_url)
if pid_path:
sabnzbd.pid_file(pid_path, cherryport)
if pid_path or pid_file:
sabnzbd.pid_file(pid_path, pid_file, cherryport)
# Start all SABnzbd tasks
logging.info('Starting %s-%s', sabnzbd.MY_NAME, sabnzbd.__version__)

9
sabnzbd/__init__.py

@ -1021,12 +1021,15 @@ def check_all_tasks():
return True
def pid_file(pid_path=None, port=0):
def pid_file(pid_path=None, pid_file= None, port=0):
""" Create or remove pid file
"""
global DIR_PID
if not sabnzbd.WIN32 and pid_path and pid_path.startswith('/'):
DIR_PID = os.path.join(pid_path, 'sabnzbd-%s.pid' % port)
if not sabnzbd.WIN32:
if pid_path and pid_path.startswith('/'):
DIR_PID = os.path.join(pid_path, 'sabnzbd-%s.pid' % port)
elif pid_file and pid_file.startswith('/'):
DIR_PID = pid_file
if DIR_PID:
try:

Loading…
Cancel
Save