From b7db432cf651d6666f3a40ac1210b03cee6ebd62 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Fri, 4 Apr 2014 19:08:57 -0400 Subject: [PATCH] CC-5709: Airtime Analyzer * Added upstart script for starting on bootup --- .../install/upstart/airtime_analyzer.conf | 11 ++++++++++ python_apps/airtime_analyzer/setup.py | 22 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 python_apps/airtime_analyzer/install/upstart/airtime_analyzer.conf diff --git a/python_apps/airtime_analyzer/install/upstart/airtime_analyzer.conf b/python_apps/airtime_analyzer/install/upstart/airtime_analyzer.conf new file mode 100644 index 000000000..a4837e50d --- /dev/null +++ b/python_apps/airtime_analyzer/install/upstart/airtime_analyzer.conf @@ -0,0 +1,11 @@ +description "Airtime Analyzer" +author "help@sourcefabric.org" + +start on runlevel [2345] +stop on runlevel [!2345] + +expect daemon +respawn + +exec sudo -u www-data airtime_analyzer --daemon + diff --git a/python_apps/airtime_analyzer/setup.py b/python_apps/airtime_analyzer/setup.py index 5691676f3..5af60a3cd 100644 --- a/python_apps/airtime_analyzer/setup.py +++ b/python_apps/airtime_analyzer/setup.py @@ -1,4 +1,14 @@ from setuptools import setup +from subprocess import call +import sys + +# Allows us to avoid installing the upstart init script when deploying airtime_analyzer +# on Airtime Pro: +if '--no-init-script' in sys.argv: + data_files = [] +else: + data_files = [('/etc/init', ['install/upstart/airtime_analyzer.conf'])] + print data_files setup(name='airtime_analyzer', version='0.1', @@ -19,4 +29,14 @@ setup(name='airtime_analyzer', 'python-daemon', 'requests', ], - zip_safe=False) + zip_safe=False, + data_files=data_files) + +# Reload the initctl config so that "service start airtime_analyzer" works +if data_files: + print "Reloading initctl configuration" + call(['initctl', 'reload-configuration']) + print "Run \"sudo service airtime_analyzer restart\" now." + + +# TODO: Should we start the analyzer here or not?