A
A
Artem Sukhov2016-12-13 00:26:51
Java
Artem Sukhov, 2016-12-13 00:26:51

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

3 answer(s)
D
Dmitry Zaitsev, 2016-12-13
@cnsass

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."

To stop:
#!/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

A
al_gon, 2016-12-13
@al_gon

Maven+Ant or just Ant, depending on how you build.

S
Saboteur, 2016-12-13
@saboteur_kiev

write a bash script that will copy the file to a remote server and restart the desired process on it (tomcat or your java)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question