diff --git a/.gitignore b/.gitignore index 0e0a2f3..ab1e0f2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__ config.py nohup.out +*conf~ diff --git a/modem.py b/modem.py index 84a85e4..657b20a 100644 --- a/modem.py +++ b/modem.py @@ -1,4 +1,6 @@ from gsmmodem.modem import GsmModem +from gsmmodem.exceptions import TimeoutException + import threading import time import logging @@ -16,7 +18,7 @@ def run(self): while True: try: self.modem.connect() - except IOError: + except (TimeoutException,IOError) as e: exc_type, exc_value, exc_traceback = sys.exc_info() logging.debug(traceback.format_tb(exc_traceback)) time.sleep(10) diff --git a/upstart/smsd.conf b/upstart/smsd.conf index 39f6775..35a59ab 100644 --- a/upstart/smsd.conf +++ b/upstart/smsd.conf @@ -5,7 +5,6 @@ respawn respawn limit 15 5 start on runlevel [2345] stop on runlevel [06] -script - cd /opt/smsd/ - python2 /opt/smsd/server.py 2>&1 >> /var/log/eri/smsd.log -end script +console log +exec python2 /opt/smsd/server.py + diff --git a/upstart/smsd.conf~ b/upstart/smsd.conf~ new file mode 100644 index 0000000..39f6775 --- /dev/null +++ b/upstart/smsd.conf~ @@ -0,0 +1,11 @@ +pre-start script + mkdir -p /var/log/eri +end script +respawn +respawn limit 15 5 +start on runlevel [2345] +stop on runlevel [06] +script + cd /opt/smsd/ + python2 /opt/smsd/server.py 2>&1 >> /var/log/eri/smsd.log +end script