From 4f050093baa1046733e7d4c0f47066c1b2945a18 Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Tue, 26 Jan 2016 09:19:15 +0200 Subject: [PATCH] Add upstart config for solar-worker In order to make GID and UID configurable those values will be souorced from /etc/default/solar-worker during pre-script and script stanzas in upstart Change-Id: I6b23e4fb176043533522a68e448fb635324fa4d2 --- bootstrap/playbooks/solar.yaml | 5 +-- bootstrap/playbooks/tasks/celery_init.yaml | 8 ----- bootstrap/playbooks/tasks/worker_upstart.yaml | 5 +++ setup.cfg | 2 -- utils/solar-celery | 33 ------------------- utils/solar-worker-defaults | 3 ++ utils/solar-worker.conf | 30 +++++++++++++++++ 7 files changed, 39 insertions(+), 47 deletions(-) delete mode 100644 bootstrap/playbooks/tasks/celery_init.yaml create mode 100644 bootstrap/playbooks/tasks/worker_upstart.yaml delete mode 100755 utils/solar-celery create mode 100644 utils/solar-worker-defaults create mode 100644 utils/solar-worker.conf diff --git a/bootstrap/playbooks/solar.yaml b/bootstrap/playbooks/solar.yaml index e3ffa48c..36561b04 100644 --- a/bootstrap/playbooks/solar.yaml +++ b/bootstrap/playbooks/solar.yaml @@ -14,9 +14,6 @@ - hosts: all tasks: - # add application related directories - - file: path=/var/log/solar state=directory owner=vagrant group=vagrant - - file: path=/var/run/celery state=directory owner=vagrant group=vagrant # setup solar-resources # change to openstack/solar-resources later - git: repo=https://github.com/Mirantis/solar-resources.git dest=/vagrant/solar-resources update=no @@ -71,4 +68,4 @@ ignore_errors: yes - shell: timeout 10 docker exec vagrant_riak_1 riak-admin bucket-type activate counters - - include: tasks/celery_init.yaml + - include: tasks/worker_upstart.yaml diff --git a/bootstrap/playbooks/tasks/celery_init.yaml b/bootstrap/playbooks/tasks/celery_init.yaml deleted file mode 100644 index 89f9ab84..00000000 --- a/bootstrap/playbooks/tasks/celery_init.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- copy: src=/vagrant/utils/solar-celery dest=/etc/init.d/solar-celery -- shell: chmod +x /etc/init.d/solar-celery -- shell: chown vagrant:vagrant /etc/init.d/solar-celery -- shell: update-rc.d solar-celery defaults -- shell: update-rc.d solar-celery enable -- shell: su vagrant service solar-celery start diff --git a/bootstrap/playbooks/tasks/worker_upstart.yaml b/bootstrap/playbooks/tasks/worker_upstart.yaml new file mode 100644 index 00000000..6eb49759 --- /dev/null +++ b/bootstrap/playbooks/tasks/worker_upstart.yaml @@ -0,0 +1,5 @@ +--- + +- copy: src=/vagrant/utils/solar-worker-defaults dest=/etc/default/solar-worker +- copy: src=/vagrant/utils/solar-worker.conf dest=/etc/init/solar-worker.conf +- shell: start solar-worker diff --git a/setup.cfg b/setup.cfg index 4859a59e..8e183af8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,8 +18,6 @@ keywords = [files] package-data = solar = ansible_library/*.py -scripts= - utils/solar-celery [build_sphinx] all_files = 1 diff --git a/utils/solar-celery b/utils/solar-celery deleted file mode 100755 index 40f66d61..00000000 --- a/utils/solar-celery +++ /dev/null @@ -1,33 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: solar-celery -# Required-Start: $syslog -# Required-Stop: $syslog -# Should-Start: $local_fs -# Should-Stop: $local_fs -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -### END INIT INFO - -export SOLAR_CONFIG_OVERRIDE=${SOLAR_CONFIG_OVERRIDE:-/.solar_config_override} -NAME=solar-celery - - -case "$1" in - start) - /usr/bin/env celery multi start 2 -A solar.orchestration.runner -P gevent -c:1 1 -c:2 1000 -Q:1 scheduler,system_log -Q:2 celery --pidfile=/var/run/celery/%N.pid --logfile=/var/run/celery/%N.log - ;; - stop) - /usr/bin/env celery multi stopwait 2 --pidfile=/var/run/celery/%N.pid - ;; - restart|force-reload) - ${0} stop - ${0} start - ;; - *) - echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/utils/solar-worker-defaults b/utils/solar-worker-defaults new file mode 100644 index 00000000..5528284c --- /dev/null +++ b/utils/solar-worker-defaults @@ -0,0 +1,3 @@ +SOLAR_UID=vagrant +SOLAR_GID=vagrant +SOLAR_PIDFILE=/var/opt/solar/solar-worker.pid diff --git a/utils/solar-worker.conf b/utils/solar-worker.conf new file mode 100644 index 00000000..26d85801 --- /dev/null +++ b/utils/solar-worker.conf @@ -0,0 +1,30 @@ +# solar-worker +# + +description "solar-worker upstart script" + +# When to start the service +start on runlevel [2345] + +# When to stop the service +stop on runlevel [06] + +# Prepare the environment +# Change ownership to the user running the process +pre-start script + . /etc/default/solar-worker + mkdir -p /var/log/solar + mkdir -p /var/opt/solar + chown -R $SOLAR_UID:$SOLAR_GID /var/log/solar + chown -R $SOLAR_UID:$SOLAR_GID /var/opt/solar +end script + +# If the process quits unexpectadly trigger a respawn +respawn + +# Start the process +script + . /etc/default/solar-worker + export SOLAR_CONFIG_OVERRIDE=/.solar_config_override + exec start-stop-daemon --start --chuid $SOLAR_UID --make-pidfile --pidfile $SOLAR_PIDFILE --exec /usr/bin/env solar-worker +end script