Skip to content

Commit

Permalink
Improve conf/ *bin/ file names and contents to better support product…
Browse files Browse the repository at this point in the history
…ion and (mac) development environments
  • Loading branch information
jpnavarro committed Nov 13, 2020
1 parent fefc622 commit 6032152
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 126 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
tag-1.4-20201113 JP
- Improve conf/ *bin/ file names and contents to better support production and (mac) development environments

tag-1.4-20201109 JP
- Send status to info-serv-alert
102 changes: 0 additions & 102 deletions sbin/route_glue2.rc

This file was deleted.

7 changes: 3 additions & 4 deletions sbin/route_glue2.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
EnvironmentFile=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/sbin/route_glue2.sysconfig
ExecStart=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/sbin/route_glue2.sh start
ExecReload=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/sbin/route_glue2.sh restart
ExecStop=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/sbin/route_glue2.sh stop
ExecStart=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/sbin/route_glue2.service.sh start
ExecReload=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/sbin/route_glue2.service.sh restart
ExecStop=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/sbin/route_glue2.service.sh stop
PIDFile=/soft/warehouse-apps-1.0/Manage-Glue2/var/route_glue2.pid
#PrivateTmp=true
User=software
Group=admin
Restart=always
Expand Down
49 changes: 49 additions & 0 deletions sbin/route_glue2.service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
do_start () {
echo -n "Starting ${APP_NAME}:"
export LD_LIBRARY_PATH=${PYTHON_BASE}/lib
source ${PIPENV_BASE}/bin/activate
exec ${PYTHON_BIN} ${APP_BIN} start ${APP_OPTS}
RETVAL=$?
}
do_stop () {
echo -n "Stopping ${APP_NAME}:"
export LD_LIBRARY_PATH=${PYTHON_BASE}/lib
source ${PIPENV_BASE}/bin/activate
exec ${PYTHON_BIN} ${APP_BIN} stop ${APP_OPTS}
RETVAL=$?
}
do_debug () {
echo -n "Debugging: ${PIPENV_BASE}/bin/python ${APP_BIN} -l debug $@ ${APP_OPTS}"
export LD_LIBRARY_PATH=${PYTHON_BASE}/lib
source ${PIPENV_BASE}/bin/activate
exec ${PYTHON_BIN} ${APP_BIN} -l debug $@ ${APP_OPTS}
RETVAL=$?
}

case "$1" in
start|stop)
do_${1} ${@:2}
;;

debug)
do_debug ${@:2}
;;

restart|reload|force-reload)
do_stop
do_start
;;

status)
echo "Haven't implemented status"
;;

*)
echo "Usage: ${APP_NAME} {start|stop|debug|restart}"
exit 1
;;

esac
echo rc=$RETVAL
exit $RETVAL
84 changes: 68 additions & 16 deletions sbin/route_glue2.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,81 @@
#!/bin/sh

### BEGIN INIT INFO
# Provides: route_glue2
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Route glue2 messages from a source to a destination
# Description: Route glue2 messages from a {file, directory, amqp} to a {directory, api}
### END INIT INFO

####### Customizations START #######
APP_NAME=route_glue2
APP_BASE=/soft/warehouse-apps-1.0/Manage-Glue2
WAREHOUSE_BASE=/soft/warehouse-1.0
# Override in shell environment
if [ -z "$PYTHON_BASE" ]; then
PYTHON_BASE=/soft/python/python-3.7.6-base
fi
DAEMON_USER=software
####### Customizations END #######

####### Everything else should be standard #######
APP_SOURCE=${APP_BASE}/PROD
WAREHOUSE_SOURCE=${WAREHOUSE_BASE}/PROD

APP_LOG=${APP_BASE}/var/${APP_NAME}.daemon.log
if [[ "$1" != --pdb && "$2" != --pdb && "$3" != --pdb && "$4" != --pdb ]]; then
exec >${APP_LOG} 2>&1
fi

APP_BIN=${APP_SOURCE}/bin/${APP_NAME}.py
APP_OPTS="-l info -c ${APP_BASE}/conf/${APP_NAME}.conf"

PYTHON_BIN=python3
export LD_LIBRARY_PATH=${PYTHON_BASE}/lib
source ${APP_BASE}/python/bin/activate

export PYTHONPATH=${APP_SOURCE}/lib:${WAREHOUSE_SOURCE}/django_xsede_warehouse
export DJANGO_CONF=${APP_BASE}/conf/django_xsede_warehouse.conf
export DJANGO_SETTINGS_MODULE=xsede_warehouse.settings

do_start () {
echo -n "Starting ${DAEMON_NAME}:"
export LD_LIBRARY_PATH=${PYTHON_BASE}/lib
source ${PIPENV_BASE}/bin/activate
${PYTHON_BIN} ${DAEMON_BIN} start ${DAEMON_OPTS}
RETVAL=$?
echo -n "Starting ${APP_NAME}:"
if [ `id -u` = 0 ] ; then
su ${DAEMON_USER} -s /bin/sh -c "${PYTHON_BIN} ${APP_BIN} start ${APP_OPTS}"
RETVAL=$?
elif [ `id -u` = `id -u ${DAEMON_USER}` ] ; then
${PYTHON_BIN} ${APP_BIN} start ${APP_OPTS}
RETVAL=$?
else
echo "Only root or ${DAEMON_USER} should run ${APP_BIN}"
RETVAL=99
fi
}
do_stop () {
echo -n "Stopping ${DAEMON_NAME}:"
export LD_LIBRARY_PATH=${PYTHON_BASE}/lib
source ${PIPENV_BASE}/bin/activate
${PYTHON_BIN} ${DAEMON_BIN} stop ${DAEMON_OPTS}
RETVAL=$?
echo -n "Stopping ${APP_NAME}:"
if [ `id -u` = 0 ] ; then
su ${DAEMON_USER} -s /bin/sh -c "${PYTHON_BIN} ${APP_BIN} stop ${APP_OPTS}"
RETVAL=$?
elif [ `id -u` = `id -u ${DAEMON_USER}` ] ; then
${PYTHON_BIN} ${APP_BIN} stop ${APP_OPTS}
RETVAL=$?
else
echo "Only root or ${DAEMON_USER} should run ${APP_BIN}"
RETVAL=99
fi
}
do_debug () {
echo -n "Debugging: ${PIPENV_BASE}/bin/python ${DAEMON_BIN} $@ ${DAEMON_OPTS}"
export LD_LIBRARY_PATH=${PYTHON_BASE}/lib
source ${PIPENV_BASE}/bin/activate
${PYTHON_BIN} ${DAEMON_BIN} $@ ${DAEMON_OPTS}
echo -n "Debugging: ${PYTHON_BIN} ${APP_BIN} $@ ${APP_OPTS}"
${PYTHON_BIN} ${APP_BIN} $@ ${APP_OPTS}
RETVAL=$?
}

case "$1" in
start|stop)
do_${1}
do_${1} ${@:2}
;;

debug)
Expand All @@ -40,7 +92,7 @@ case "$1" in
;;

*)
echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
echo "Usage: ${APP_NAME} {start|stop|debug|restart} [<optional_parameters>]"
exit 1
;;

Expand Down
9 changes: 5 additions & 4 deletions sbin/route_glue2.sysconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
DAEMON_NAME=route_glue2
DAEMON_BIN=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/bin/route_glue2.py
APP_NAME=route_glue2
APP_BASE=/soft/warehouse-apps-1.0/Manage-Glue2
APP_BIN=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/bin/route_glue2.py
# Add any command line options for your daemon here
DAEMON_OPTS="-l info -c /soft/warehouse-apps-1.0/Manage-Glue2/conf/route_glue2.conf"
APP_OPTS="-l info -c /soft/warehouse-apps-1.0/Manage-Glue2/conf/route_glue2.conf"

APP_BASE=/soft/warehouse-apps-1.0/Manage-Glue2
PYTHON_BASE=/soft/python/python-3.7.5-base
PIPENV_BASE=/soft/warehouse-apps-1.0/Manage-Glue2/python
PYTHON_BIN=python3
PYTHONPATH=/soft/warehouse-apps-1.0/Manage-Glue2/PROD/lib:/soft/warehouse-1.0/PROD/django_xsede_warehouse

DJANGO_CONF=/soft/warehouse-apps-1.0/Manage-Glue2/conf/django_xsede_warehouse.conf
DJANGO_SETTINGS_MODULE=xsede_warehouse.settings

0 comments on commit 6032152

Please sign in to comment.