aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srtmain/wsgi.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/srtmain/wsgi.py')
-rw-r--r--lib/srtmain/wsgi.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/srtmain/wsgi.py b/lib/srtmain/wsgi.py
index 6b468e4f..42259a79 100644
--- a/lib/srtmain/wsgi.py
+++ b/lib/srtmain/wsgi.py
@@ -17,12 +17,29 @@ framework.
"""
import os
+from dotenv import load_dotenv
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "Toaster.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "srtmain.settings")
+SRT_BASE_DIR = os.environ.get('SRT_BASE_DIR','.')
+PIDFILE = os.environ.get('PIDFILE','.')
+
+# quick development/debugging support
+def _log(msg):
+ f1=open(f"{SRT_BASE_DIR}/gunicorn_env.txt", 'w')
+ f1.write("|" + msg + "|\n" )
+ f1.close()
+
+# Spawn the updater, if not already running
+_log(str(os.environ))
+is_update_pid = os.path.isfile(f"{SRT_BASE_DIR}/.srtupdate.pid")
+if False and SRT_BASE_DIR and PIDFILE and (not is_update_pid):
+ cmnd = [f"{SRT_BASE_DIR}/bin/srt","start_update",f"update_follow_pid={PIDFILE}"]
+ _log(f"COMMAND:{cmnd}")
+ os.spawnv(os.P_NOWAIT, cmnd[0], cmnd)
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION