diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-10-03 17:54:19 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-10-03 17:54:19 +0000 |
commit | 6da3c5e6a2f6478ea3fecc723eadf2a4562a97d2 (patch) | |
tree | 5525f7bb2966cd2ea012ac3096cc3b2ed1842a6b | |
parent | 7c1f90bac429ef39ae3d1c6b4aece03e24202a96 (diff) | |
parent | 88dd2af107447585cb888db55d6f7e931d32783e (diff) | |
download | ick2-6da3c5e6a2f6478ea3fecc723eadf2a4562a97d2.tar.gz |
Merge fixes to make a deploy work
With these changes, an ick2.deb package will bring up a controller,
after a config file is set up.
-rw-r--r-- | debian/control | 2 | ||||
-rw-r--r-- | ick2.service | 5 | ||||
-rw-r--r-- | ick_controller.py | 23 |
3 files changed, 27 insertions, 3 deletions
diff --git a/debian/control b/debian/control index dc868f9..f8f99ab 100644 --- a/debian/control +++ b/debian/control @@ -22,6 +22,6 @@ Build-Depends: debhelper (>= 9~), Package: ick2 Architecture: all -Depends: ${python3:Depends}, ${misc:Depends}, python3-bottle, python-cliapp, python3-yaml +Depends: ${python3:Depends}, ${misc:Depends} Description: a work-in-progress CI server This should be written. diff --git a/ick2.service b/ick2.service index 3e661ff..112b772 100644 --- a/ick2.service +++ b/ick2.service @@ -13,7 +13,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. [Unit] -Description=uWSGI instance to serve Ick2 controller +Description=ick2 controller After=network.target [Service] @@ -21,7 +21,8 @@ Type=simple User=www-data Group=www-data WorkingDirectory=/var/lib/ick2 -ExecStart=/usr/bin/uwsgi --ini /etc/ick2/uwsgi.ini +Environment=ICK_CONTROLLER_CONFIG=/etc/ick/controller.conf +ExecStart=/usr/bin/gunicorn3 --daemon --bind 127.0.0.1:12765 --log-file /var/log/gunicorn3.log --log-level debug ick_controller:app KillSignal=QUIT [Install] diff --git a/ick_controller.py b/ick_controller.py index a029145..5d3c5e3 100644 --- a/ick_controller.py +++ b/ick_controller.py @@ -15,6 +15,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import logging +import logging.handlers import os @@ -53,16 +55,37 @@ def load_config(filename, defconf): return actual_config +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) +handler = logging.handlers.SysLogHandler(address='/dev/log') +logger.addHandler(handler) +logging.info('Starting ick controller main program') + config_filename = os.environ.get('ICK_CONTROLLER_CONFIG') +logging.info('config filename %r', config_filename) if not config_filename: + logging.error('no ICK_CONTROLLER_CONFIG in environment') raise Exception('No ICK_CONTROLLER_CONFIG defined in environment') + +logging.info('reading config from %r', config_filename) config = load_config(config_filename, default_config) + +logging.info('config is %r', config) ick2.setup_logging(config) + ick2.log.log('info', msg_text='Ick2 controller starts', config=config) + api = ick2.ControllerAPI() +ick2.log.log('info', msg_text='created ControllerAPI') + api.set_state_directory(config['statedir']) +ick2.log.log('info', msg_text='called ControllerAPI.set_state_directory') + api.load_projects() +ick2.log.log('info', msg_text='called ControllerAPI.load_projects') + app = apifw.create_bottle_application(api, counter, dict_logger, config) +ick2.log.log('info', msg_text='called apifw.create_bottle_application') # If we are running this program directly with Python, and not via # gunicorn, we can use the Bottle built-in debug server, which can |