Skip to content

Commit

Permalink
Fix all the sbin/ scripts and files for to latest approach used in re…
Browse files Browse the repository at this point in the history
…source_v3
  • Loading branch information
jpnavarro committed Dec 8, 2023
1 parent 827f16d commit c5114b1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 93 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v2.4.1 20231208 JP
- Fix all the sbin/ scripts and files for to latest approach used in resource_v3

v2.4.0 20231208 JP
- Convert to new CiDeR resource response format with typed resources and no sub-resources
- Upgrade daemonaction(obsolete) and --once to latest approach used in resource_v3
Expand Down
2 changes: 1 addition & 1 deletion sbin/router_cider.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=ACCESS CONECT Information Sharing Platform CiDeR Router
Description=Information Sharing Platform CiDeR Router
After=network.target remote-fs.target nss-lookup.target

[Service]
Expand Down
20 changes: 4 additions & 16 deletions sbin/router_cider.service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ 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}
exec ${PYTHON_BIN} ${APP_BIN} --daemon $@ ${APP_OPTS}
RETVAL=$?
}
do_debug () {
Expand All @@ -22,21 +15,16 @@ do_debug () {
}

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

debug)
do_debug ${@:2}
;;

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

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

Expand Down
82 changes: 7 additions & 75 deletions sbin/router_cider.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
#!/bin/sh

### BEGIN INIT INFO
# Provides: %APP_NAME%
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ACCESS CONECT Information Sharing Platform CiDeR Router
# Description: Route CiDeR information from the authoritative source (database) to the warehouse
### END INIT INFO
###
# Run %APP_NAME% interactively
###

####### Customizations START #######
APP_NAME=%APP_NAME%
APP_HOME=%APP_HOME%
WAREHOUSE_DJANGO=%WAREHOUSE_DJANGO%
# Override in shell environment
if [ -z "$PYTHON_BASE" ]; then
PYTHON_BASE=%PYTHON_BASE%
fi
DAEMON_USER=software
####### Customizations END #######

####### Everything else should be standard #######
APP_SOURCE=${APP_HOME}/PROD

APP_LOG=${APP_HOME}/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="-c ${APP_HOME}/conf/${APP_NAME}.conf"
APP_OPTS="-l info -c ${APP_HOME}/conf/${APP_NAME}.conf"

PYTHON_BIN=python3
export LD_LIBRARY_PATH=${PYTHON_BASE}/lib
Expand All @@ -40,61 +25,8 @@ export PYTHONPATH=${APP_SOURCE}/lib:${WAREHOUSE_DJANGO}
export APP_CONFIG=${APP_HOME}/conf/django_prod_router.conf
export DJANGO_SETTINGS_MODULE=Operations_Warehouse_Django.settings

do_start () {
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 ${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: ${PYTHON_BIN} ${APP_BIN} $@ ${APP_OPTS}"
${PYTHON_BIN} ${APP_BIN} start $@ ${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} [<optional_parameters>]"
exit 1
;;

esac
echo "Starting: ${PYTHON_BIN} ${APP_BIN} $@ ${APP_OPTS}"
${PYTHON_BIN} ${APP_BIN} $@ ${APP_OPTS}
RETVAL=$?
echo rc=$RETVAL
exit $RETVAL
2 changes: 1 addition & 1 deletion sbin/router_cider.sysconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ APP_NAME=%APP_NAME%
APP_HOME=%APP_HOME%
APP_BIN=%APP_HOME%/PROD/bin/%APP_NAME%.py
# Add any command line options for your daemon here
APP_OPTS="-c %APP_HOME%/conf/%APP_NAME%.conf"
APP_OPTS="-l info -c %APP_HOME%/conf/%APP_NAME%.conf"

PYTHON_BASE=%PYTHON_BASE%
PIPENV_BASE=%APP_HOME%/python
Expand Down

0 comments on commit c5114b1

Please sign in to comment.