From b3fe6145e224d5410382a2959437bfa037758148 Mon Sep 17 00:00:00 2001 From: Vashypooh Date: Sat, 22 Jul 2017 16:02:42 -0400 Subject: [PATCH 01/11] Added support for windows service Added support for running as a windows service so it does not fork the process on reboot. --- PlexPy.py | 8 +++++++- plexpy/__init__.py | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/PlexPy.py b/PlexPy.py index 903ce790..68ed8198 100755 --- a/PlexPy.py +++ b/PlexPy.py @@ -92,7 +92,9 @@ def main(): '--nolaunch', action='store_true', help='Prevent browser from launching on startup') parser.add_argument( '--pidfile', help='Create a pid file (only relevant when running as a daemon)') - + parser.add_argument( + '--windowsservice', action='store_true', help='Running as a windows service.') + args = parser.parse_args() if args.verbose: @@ -116,6 +118,10 @@ def main(): plexpy.DAEMON = True plexpy.QUIET = True + if args.windowsservice: + plexpy.WINDOWSSERVICE = True + logger.info("Running as windows service: %s", plexpy.WINDOWSSERVICE) + if args.pidfile: plexpy.PIDFILE = str(args.pidfile) diff --git a/plexpy/__init__.py b/plexpy/__init__.py index d89845ee..9dcf1609 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -54,6 +54,7 @@ VERBOSE = True DAEMON = False CREATEPID = False PIDFILE = None +WINDOWSSERVICE = False SCHED = BackgroundScheduler() SCHED_LOCK = threading.Lock() @@ -989,15 +990,17 @@ def shutdown(restart=False, update=False): args += ARGS if '--nolaunch' not in args: args += ['--nolaunch'] - logger.info('Restarting PlexPy with %s', args) # os.execv fails with spaced names on Windows # https://bugs.python.org/issue19066 - if os.name == 'nt': + if os.name == 'nt' and plexpy.WINDOWSSERVICE: + logger.info("Running as windows service, no need to fork.") + elif os.name == 'nt': subprocess.Popen(args, cwd=os.getcwd()) + logger.info('Restarting PlexPy with %s', args) else: os.execv(exe, args) - + logger.info('Restarting PlexPy with %s', args) os._exit(0) From 532ff59dfe7d0fe9e39a8f4bfa990e9527d599bc Mon Sep 17 00:00:00 2001 From: Joshua Dehler Date: Fri, 8 Sep 2017 20:13:07 +0200 Subject: [PATCH 02/11] Fix web 3.20.5 urls --- data/interfaces/default/info.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html index 1075b047..30bda4ab 100644 --- a/data/interfaces/default/info.html +++ b/data/interfaces/default/info.html @@ -115,9 +115,9 @@ DOCUMENTATION :: END