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
This commit is contained in:
Dmitry Shulyak 2016-01-26 09:19:15 +02:00
parent 1d7b37f499
commit 4f050093ba
7 changed files with 39 additions and 47 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -18,8 +18,6 @@ keywords =
[files]
package-data = solar = ansible_library/*.py
scripts=
utils/solar-celery
[build_sphinx]
all_files = 1

View File

@ -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

View File

@ -0,0 +1,3 @@
SOLAR_UID=vagrant
SOLAR_GID=vagrant
SOLAR_PIDFILE=/var/opt/solar/solar-worker.pid

30
utils/solar-worker.conf Normal file
View File

@ -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