Попробуй gradle и несколько плагинов shadow jar +
https://gradle-ssh-plugin.github.io Для старта и рестарта jar придется написать просто bash скрипт:
Для старта (app.jar)
#!/usr/bin/env bash
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
APP_HOME=$(dirname "$(realpath "$0")")
APP_PID=$(<"$APP_HOME/app.pid")
if ps -p $APP_PID > /dev/null
then
echo "Failed to start, service already started!"
exit 1
fi
nohup java -jar -Dfile.ecoding=UTF-8 "$APP_HOME/app.jar" > "$APP_HOME/app.log" 2>&1 &
APP_PID=$!
echo $APP_PID > "$APP_HOME/app.pid"
echo "App has been started, pid = $APP_PID."
Для остановки:
#!/usr/bin/env bash
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
APP_HOME=$(dirname "$(realpath "$0")")
APP_PID=$(<"$APP_HOME/app.pid")
if ps -p $APP_PID > /dev/null
then
echo "Shutdown app with pid = $APP_PID ..."
kill -15 "$APP_PID"
while ps -p $APP_PID > /dev/null
do
echo "Waiting ..."
sleep 0.3
done
echo "Done!"
else
echo "App is not running."
fi