From bce460e367af52fdae8cd582639d57a6e9e0201d Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Wed, 17 Aug 2016 15:20:37 +0000 Subject: [PATCH] Condense amphora-agent-ubuntu in to amphora-agent This reverts commit fdde4e69846bda02e49c636fed991ba86318183d. This was reverted due to an issue with starting the service on boot. A trick of using symlinks was being attempted in order to refer to files in the base source directory from an element. This seems to not work, so copying init scripts in to the elments themselves. Change-Id: If6ae07fa4ab4f39e2a339e17fbcc163b863ccd3a --- elements/amphora-agent-ubuntu/README.rst | 3 - elements/amphora-agent-ubuntu/element-deps | 2 +- .../install.d/75-run_setup_install | 13 ---- .../source-repository-amphora-agent | 2 - elements/amphora-agent-ubuntu/svc-map | 2 - .../init-scripts/sysv/amphora-agent | 68 ++++++++++++++++++- .../init-scripts/upstart/amphora-agent.conf | 10 ++- etc/init/amphora-agent.conf | 9 --- etc/initd/amphora-agent | 67 ------------------ 9 files changed, 77 insertions(+), 99 deletions(-) delete mode 100644 elements/amphora-agent-ubuntu/README.rst delete mode 100755 elements/amphora-agent-ubuntu/install.d/75-run_setup_install delete mode 100644 elements/amphora-agent-ubuntu/source-repository-amphora-agent delete mode 100644 elements/amphora-agent-ubuntu/svc-map mode change 120000 => 100644 elements/amphora-agent/init-scripts/sysv/amphora-agent mode change 120000 => 100644 elements/amphora-agent/init-scripts/upstart/amphora-agent.conf delete mode 100644 etc/init/amphora-agent.conf delete mode 100644 etc/initd/amphora-agent diff --git a/elements/amphora-agent-ubuntu/README.rst b/elements/amphora-agent-ubuntu/README.rst deleted file mode 100644 index 2b6ca5f60d..0000000000 --- a/elements/amphora-agent-ubuntu/README.rst +++ /dev/null @@ -1,3 +0,0 @@ -Element to install an Octavia Amphora agent. - - diff --git a/elements/amphora-agent-ubuntu/element-deps b/elements/amphora-agent-ubuntu/element-deps index 715c11e2f5..6efeb1fe06 100644 --- a/elements/amphora-agent-ubuntu/element-deps +++ b/elements/amphora-agent-ubuntu/element-deps @@ -1 +1 @@ -source-repositories +amphora-agent diff --git a/elements/amphora-agent-ubuntu/install.d/75-run_setup_install b/elements/amphora-agent-ubuntu/install.d/75-run_setup_install deleted file mode 100755 index c02ab7dc57..0000000000 --- a/elements/amphora-agent-ubuntu/install.d/75-run_setup_install +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -eux - -install-packages libffi-dev libssl-dev -cd /opt/amphora-agent/ -pip install -r requirements.txt -python setup.py install -cp etc/init/amphora-agent.conf /etc/init/ -mkdir /etc/octavia -# we assume certs, etc will come in through the config drive -mkdir /etc/octavia/certs -mkdir /var/lib/octavia - diff --git a/elements/amphora-agent-ubuntu/source-repository-amphora-agent b/elements/amphora-agent-ubuntu/source-repository-amphora-agent deleted file mode 100644 index 456d3f522a..0000000000 --- a/elements/amphora-agent-ubuntu/source-repository-amphora-agent +++ /dev/null @@ -1,2 +0,0 @@ -# This is temporary until we have a pip package -amphora-agent git /opt/amphora-agent https://git.openstack.org/openstack/octavia diff --git a/elements/amphora-agent-ubuntu/svc-map b/elements/amphora-agent-ubuntu/svc-map deleted file mode 100644 index b850c874db..0000000000 --- a/elements/amphora-agent-ubuntu/svc-map +++ /dev/null @@ -1,2 +0,0 @@ -amphora-agent: - default: amphora-agent diff --git a/elements/amphora-agent/init-scripts/sysv/amphora-agent b/elements/amphora-agent/init-scripts/sysv/amphora-agent deleted file mode 120000 index 38bfd27161..0000000000 --- a/elements/amphora-agent/init-scripts/sysv/amphora-agent +++ /dev/null @@ -1 +0,0 @@ -etc/initd/amphora-agent \ No newline at end of file diff --git a/elements/amphora-agent/init-scripts/sysv/amphora-agent b/elements/amphora-agent/init-scripts/sysv/amphora-agent new file mode 100644 index 0000000000..d191874bb5 --- /dev/null +++ b/elements/amphora-agent/init-scripts/sysv/amphora-agent @@ -0,0 +1,67 @@ +### BEGIN INIT INFO +# Provides: amphora-agent +# Required-Start: $remote_fs $syslog $network +# Required-Stop: $remote_fs $syslog $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Runs the Amphora Agent processes +# Description: This script runs Octavia Amphora Agent processes. +# This script will start the Amphora Agent services +# and kill them. +### END INIT INFO + +# Using the lsb functions to perform the operations. +. /lib/lsb/init-functions +# Process name ( For display ) +NAME=amphora-agent +# Daemon name, where is the actual executable +DAEMON=/usr/local/bin/amphora-agent +# pid file for the daemon +PIDFILE=/var/run/amphora-agent.pid + +# If the daemon is not there, then exit. +test -x $DAEMON || exit 5 + +case $1 in + start) + # Checked the PID file exists and check the actual status of process + if [ -e $PIDFILE ]; then + status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?" + # If the status is SUCCESS then don't need to start again. + if [ $status = "0" ]; then + exit # Exit + fi + fi + # Start the daemon. + log_daemon_msg "Starting the process" "$NAME" + # Start the daemon with the help of start-stop-daemon + # Log the message appropriately + if start-stop-daemon --start -m --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- --config-file /etc/octavia/amphora-agent.conf ; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + stop) + # Stop the daemon. + if [ -e $PIDFILE ]; then + status_of_proc -p $PIDFILE $DAEMON "Stoppping the $NAME process" && status="0" || status="$?" + if [ "$status" = 0 ]; then + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE + /bin/rm -rf $PIDFILE + fi + else + log_daemon_msg "$NAME process is not running" + log_end_msg 0 + fi + ;; + restart) + # Restart the daemon. + $0 stop && sleep 2 && $0 start + ;; + *) + # For invalid arguments, print the usage message. + echo "Usage: $0 {start|stop|restart|reload|status}" + exit 2 + ;; +esac diff --git a/elements/amphora-agent/init-scripts/upstart/amphora-agent.conf b/elements/amphora-agent/init-scripts/upstart/amphora-agent.conf deleted file mode 120000 index 7772b87a15..0000000000 --- a/elements/amphora-agent/init-scripts/upstart/amphora-agent.conf +++ /dev/null @@ -1 +0,0 @@ -etc/init/amphora-agent.conf \ No newline at end of file diff --git a/elements/amphora-agent/init-scripts/upstart/amphora-agent.conf b/elements/amphora-agent/init-scripts/upstart/amphora-agent.conf new file mode 100644 index 0000000000..1f93b0ff33 --- /dev/null +++ b/elements/amphora-agent/init-scripts/upstart/amphora-agent.conf @@ -0,0 +1,9 @@ +description "Start up the Octavia Amphora Agent" + +start on runlevel [2345] +stop on runlevel [!2345] + +respawn +respawn limit 2 2 + +exec amphora-agent --config-file /etc/octavia/amphora-agent.conf diff --git a/etc/init/amphora-agent.conf b/etc/init/amphora-agent.conf deleted file mode 100644 index 1f93b0ff33..0000000000 --- a/etc/init/amphora-agent.conf +++ /dev/null @@ -1,9 +0,0 @@ -description "Start up the Octavia Amphora Agent" - -start on runlevel [2345] -stop on runlevel [!2345] - -respawn -respawn limit 2 2 - -exec amphora-agent --config-file /etc/octavia/amphora-agent.conf diff --git a/etc/initd/amphora-agent b/etc/initd/amphora-agent deleted file mode 100644 index d191874bb5..0000000000 --- a/etc/initd/amphora-agent +++ /dev/null @@ -1,67 +0,0 @@ -### BEGIN INIT INFO -# Provides: amphora-agent -# Required-Start: $remote_fs $syslog $network -# Required-Stop: $remote_fs $syslog $network -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Runs the Amphora Agent processes -# Description: This script runs Octavia Amphora Agent processes. -# This script will start the Amphora Agent services -# and kill them. -### END INIT INFO - -# Using the lsb functions to perform the operations. -. /lib/lsb/init-functions -# Process name ( For display ) -NAME=amphora-agent -# Daemon name, where is the actual executable -DAEMON=/usr/local/bin/amphora-agent -# pid file for the daemon -PIDFILE=/var/run/amphora-agent.pid - -# If the daemon is not there, then exit. -test -x $DAEMON || exit 5 - -case $1 in - start) - # Checked the PID file exists and check the actual status of process - if [ -e $PIDFILE ]; then - status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?" - # If the status is SUCCESS then don't need to start again. - if [ $status = "0" ]; then - exit # Exit - fi - fi - # Start the daemon. - log_daemon_msg "Starting the process" "$NAME" - # Start the daemon with the help of start-stop-daemon - # Log the message appropriately - if start-stop-daemon --start -m --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- --config-file /etc/octavia/amphora-agent.conf ; then - log_end_msg 0 - else - log_end_msg 1 - fi - ;; - stop) - # Stop the daemon. - if [ -e $PIDFILE ]; then - status_of_proc -p $PIDFILE $DAEMON "Stoppping the $NAME process" && status="0" || status="$?" - if [ "$status" = 0 ]; then - start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE - /bin/rm -rf $PIDFILE - fi - else - log_daemon_msg "$NAME process is not running" - log_end_msg 0 - fi - ;; - restart) - # Restart the daemon. - $0 stop && sleep 2 && $0 start - ;; - *) - # For invalid arguments, print the usage message. - echo "Usage: $0 {start|stop|restart|reload|status}" - exit 2 - ;; -esac