aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/client.py5
-rw-r--r--python/client_daemon.py9
-rw-r--r--python/master.py5
3 files changed, 11 insertions, 8 deletions
diff --git a/python/client.py b/python/client.py
index cb111dd9..63255412 100644
--- a/python/client.py
+++ b/python/client.py
@@ -2,8 +2,6 @@ import redis
import tasks
from pickle import loads, dumps
import socket
-import daemon
-from daemon.pidlockfile import TimeoutPIDLockFile
def run():
hostname = socket.gethostname()
@@ -21,5 +19,4 @@ def run():
q.rpush("tasks", dumps(("generate_scenarios", args[:-1]), protocol=2))
if __name__=="__main__":
- with daemon.DaemonContext(pidfile = TimeoutPIDLockFile('/var/run/client.pid',10)):
- run()
+ run()
diff --git a/python/client_daemon.py b/python/client_daemon.py
new file mode 100644
index 00000000..4384aa35
--- /dev/null
+++ b/python/client_daemon.py
@@ -0,0 +1,9 @@
+import sys
+import daemon
+import importlib
+from daemon.pidlockfile import TimeoutPIDLockFile
+pgr_name = sys.argv[0].split("_")[0]
+m = importlib.import_module(pgr_name)
+
+with daemon.DaemonContext(pidfile = TimeoutPIDLockFile('/var/run/{0}.pid'.format(pgr_name),10)):
+ m.run()
diff --git a/python/master.py b/python/master.py
index c45c1cf2..42092da7 100644
--- a/python/master.py
+++ b/python/master.py
@@ -4,8 +4,6 @@ import datetime
import os
import time
from common import root
-import daemon
-from daemon.pidlockfile import TimeoutPIDLockFile
def run():
dealsfile = os.path.join(root, "scripts", "deals_to_price.txt")
@@ -22,5 +20,4 @@ def run():
time.sleep(3)
if __name__=="__main__":
- with daemon.DaemonContext(pidfile = TimeoutPIDLockFile('/var/run/master.pid',10)):
- run()
+ run()