Got automatic Bridgehead restart to work

Cherry picked from ehds2_develop branch
This commit is contained in:
DavidCroftDKFZ 2024-07-18 12:47:47 +02:00
parent 1b9af45991
commit 56cdd0dcc4
3 changed files with 19 additions and 11 deletions

View File

@ -5,10 +5,10 @@ Description=Start ECDC Bridgehead
Type=simple Type=simple
ExecStart=/srv/docker/bridgehead/restart_service.sh ExecStart=/srv/docker/bridgehead/restart_service.sh
ExecStop=/srv/docker/bridgehead/shutdown_service.sh ExecStop=/srv/docker/bridgehead/shutdown_service.sh
Restart=on-failure Restart=always
RestartSec=36000 RestartSec=36000
KillMode=mixed KillMode=mixed
[Install] [Install]
WantedBy=multi.user.target WantedBy=default.target

16
run.sh
View File

@ -48,12 +48,12 @@ if [ "$UPLOAD" = true ] && [ "$UPLOAD_ALL" = true ]; then
fi fi
# Disable/stop standard Bridgehead systemctl services, if present # Disable/stop standard Bridgehead systemctl services, if present
sudo systemctl disable bridgehead@bbmri.service sudo systemctl disable bridgehead@bbmri.service >& /dev/null
sudo systemctl disable system-bridgehead.slice sudo systemctl disable system-bridgehead.slice >& /dev/null
sudo systemctl disable bridgehead-update@bbmri.timer sudo systemctl disable bridgehead-update@bbmri.timer >& /dev/null
sudo systemctl stop bridgehead@bbmri.service sudo systemctl stop bridgehead@bbmri.service >& /dev/null
sudo systemctl stop system-bridgehead.slice sudo systemctl stop system-bridgehead.slice >& /dev/null
sudo systemctl stop bridgehead-update@bbmri.timer sudo systemctl stop bridgehead-update@bbmri.timer >& /dev/null
# Set up systemctl for EHDS2/ECDC if necessary # Set up systemctl for EHDS2/ECDC if necessary
cp /srv/docker/bridgehead/ecdc.service /etc/systemd/system cp /srv/docker/bridgehead/ecdc.service /etc/systemd/system
@ -77,3 +77,7 @@ fi
# Start up the Bridgehead # Start up the Bridgehead
sudo systemctl start ecdc.service sudo systemctl start ecdc.service
# Show status of Bridgehead service
sleep 10
systemctl status ecdc.service

10
stop.sh
View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Shut down a running Bridgehead and disable auto restart. # Shut down a running Bridgehead.
# Behind the scenes we use systemctl to do the work. # Behind the scenes we use systemctl to do the work.
# Function to print usage # Function to print usage
print_usage() { print_usage() {
echo "Stop the running Bridgehead, disable auto-restart" echo "Stop the running Bridgehead"
echo "Usage: $0 [--help | -h]" echo "Usage: $0 [--help | -h]"
echo "Options:" echo "Options:"
echo " --help, -h Display this help message." echo " --help, -h Display this help message."
@ -34,6 +34,10 @@ systemctl daemon-reload
systemctl enable ecdc.service systemctl enable ecdc.service
# Use systemctl to stop the Bridgehead if it is running # Use systemctl to stop the Bridgehead if it is running
sudo systemctl disable ecdc.service
sudo systemctl stop ecdc.service sudo systemctl stop ecdc.service
# Show status of Bridgehead service
sleep 20
systemctl status ecdc.service
docker ps