Skip to content

Commit

Permalink
Make 'reset' internal restart services. #1482
Browse files Browse the repository at this point in the history
  • Loading branch information
mfeit-internet2 committed Oct 22, 2024
1 parent 4fc12ee commit 74fd80f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pscheduler-server/pscheduler-server/database/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ SQL=$(BUILD_SUPER_SQL) $(BUILD_SQL) $(TEARDOWN_SQL)
INTERNALS=\
db-connections \
db-change-password \
db-reset \
db-update \
key \
purge-runs \
psql \
reset \
warmboot


Expand Down
1 change: 1 addition & 0 deletions pscheduler-server/pscheduler-server/utilities/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ COMMANDS=\
validate-configurables

INTERNALS=\
reset \
service

default: build
Expand Down
49 changes: 49 additions & 0 deletions pscheduler-server/pscheduler-server/utilities/reset.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
#
# Do a full reset on pScheduler
#

if [ "$(id -u)" != "0" ]
then
echo "This must be done as root." 1>&2
exit 1
fi

INTERACTIVE=false

if [ -t 0 -a -t 1 -a -t 2 ]
then
INTERACTIVE=true
cat <<EOF
WARNING
You are about to obliterate all stored data in pScheduler on this host.
Please confirm this by typing today's date in YYYY-MM-DD format at the
prompt below.
EOF
printf "Confirm (YYYY-MM-DD): "
read DATE
if [ "${DATE}" != "$(date +%F)" ]
then
printf "\nDate does not match today's date. Doing nothing.\n\n"
exit 1
fi

fi


${INTERACTIVE} && printf "\n"
pscheduler internal service stop

${INTERACTIVE} && printf "\nClearing all pScheduler data..."
pscheduler internal db-reset < /dev/null
${INTERACTIVE} && printf " Done.\n\n"

pscheduler internal service start

${INTERACTIVE} && printf "\n\nDone. Hope you meant to do that.\n\n"

exit 0
12 changes: 9 additions & 3 deletions pscheduler-server/pscheduler-server/utilities/service.raw
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ COMMAND="$1"
shift

case "${COMMAND}" in
stop|start|restart)
true
stop)
OP='Stopping'
;;
start)
OP='Starting'
;;
restart)
OP='Restarting'
;;
*)
die "Unknown command '${COMMAND}'"
Expand Down Expand Up @@ -70,7 +76,7 @@ else
ARGS="ticker scheduler runner archiver api"
fi

$INTERACTIVE && printf "Performing %s:" "${COMMAND}"
$INTERACTIVE && printf "%s:" "${OP}"
for SERVICE in ${ARGS}
do

Expand Down

0 comments on commit 74fd80f

Please sign in to comment.