Answer the question
In order to leave comments, you need to log in
Easiest deploy jar to linux server?
There is a server on sockets, now my manual intergration looks like this:
1. I write the code;
2. I make a build;
3. Upload to the server;
4. I stop the old one;
5. I start a new one;
What can be used to deploy directly to the server?
Answer the question
In order to leave comments, you need to log in
Try gradle and some shadow jar plugins + https://gradle-ssh-plugin.github.io To start and restart the jar, you just have to write a bash script:
To start (app.jar)
#!/usr/bin/env bash
realpath() {
&& 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() {
&& 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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question