From 85563072fb66cbd0784af6ecbbd7ac9a6fc0763e Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Fri, 27 Mar 2015 12:57:32 +0300 Subject: [PATCH] daemon is optional now --- server/borders_daemon.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/borders_daemon.py b/server/borders_daemon.py index 02adbeb..bc3ae19 100755 --- a/server/borders_daemon.py +++ b/server/borders_daemon.py @@ -1,14 +1,18 @@ #!/usr/bin/python -from daemon import runner import os, sys import time import logging import psycopg2 +import config +try: + from daemon import runner + HAS_DAEMON = True +except: + HAS_DAEMON = False FILENAME = 'borders-daemon-status.txt' #FILEPATH = '/var/run/' + FILENAME FILEPATH = '/Users/ilyazverev/Sites/' + FILENAME -CONNECTION = 'dbname=borders' class App(): def __init__(self): @@ -40,7 +44,7 @@ class App(): return res[0] if res else None def run(self): - self.conn = psycopg2.connect(CONNECTION) + self.conn = psycopg2.connect(config.CONNECTION) self.conn.autocommit = True while True: region = self.find_region() @@ -61,7 +65,7 @@ def init_logger(): if __name__ == '__main__': app = App() logger = init_logger() - if len(sys.argv) > 1 and sys.argv[1] == 'run': + if not HAS_DAEMON or (len(sys.argv) > 1 and sys.argv[1] == 'run'): app.run() else: r = runner.DaemonRunner(app)