Added hal.service file for systemd and updated the run script to support forground execution
This commit is contained in:
parent
5e3b103815
commit
e57d62471b
2 changed files with 69 additions and 7 deletions
16
hal.service
Normal file
16
hal.service
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# This is a SystemD configuration for the Hal Server.
|
||||||
|
#
|
||||||
|
# To activate the service run:
|
||||||
|
# - sudo cp hal.service /lib/systemd/system/
|
||||||
|
# - sudo systemctl enable hal.service
|
||||||
|
#
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Hal Server
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=idle
|
||||||
|
ExecStart=/home/pi/repo/hal/run.sh --forground
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
60
run.sh
60
run.sh
|
|
@ -1,12 +1,58 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#ant clean
|
# -----------------------------------------------
|
||||||
|
# User input
|
||||||
|
# -----------------------------------------------
|
||||||
|
|
||||||
|
function printHelp() {
|
||||||
|
echo "Run code analysis through SonarQube.
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
$(basename $0)
|
||||||
|
[-f|--foreground]
|
||||||
|
[-h|--help]
|
||||||
|
|
||||||
|
Where:
|
||||||
|
--foreground Run Hal Server in the foreground instead of detatching a new screen.
|
||||||
|
--help Print this help message.
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
MODE="SCREEN"
|
||||||
|
|
||||||
|
until [[ $# -eq 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-f|--forground)
|
||||||
|
MODE="FORGROUND"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown input parameter: $1=$2"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# Execute
|
||||||
|
# -----------------------------------------------
|
||||||
|
|
||||||
|
# Build Hal source
|
||||||
./gradlew build
|
./gradlew build
|
||||||
|
|
||||||
# Kill current session
|
if [[ ${MODE} == "FORGROUND" ]]; then
|
||||||
screen -S hal -X kill
|
./gradlew run
|
||||||
# Start new session
|
else
|
||||||
screen -S hal -L -d -m ./gradlew run
|
# Kill current session
|
||||||
|
screen -S hal -X kill
|
||||||
|
# Start new session
|
||||||
|
screen -S hal -L -d -m ./gradlew run
|
||||||
|
|
||||||
|
echo "-------------------------"
|
||||||
|
screen -list
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "-----------------"
|
|
||||||
screen -list
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue