A Spring War Deployment Bash Script

NixMash

WordPress Site Management for Small Business

Home

Search

Tags

Services

Contact Me

I blogged on how to deploy your Executable Spring War file on a public-facing server. Today we’re going to make that process even easier by automating server deployment in bash.

We packaged up our War executable in IntelliJ and Gradle (see the earlier post) and will now perform the following steps in bash.

Mount our remote server as a local drive. We’ll be using my Linode Cloud Server in the example

Copy our War file to the remote server

Kill the existing War process on the remote server

Launch our new Spring War

We’ll need two bash scripts, one to mount our Remote Server and copy the War, and a second script to kill the existing War process on the remote server and launch the new site. We need two scripts because the second script obviously has to be executed on the remote server to which we’ve connected with an SSH Terminal Session.

Here’s the first script we’ll run. We’re going to check if our /linode remote has been mounted and if not mount it. Then we’ll copy the War from where it was created in IntelliJ and place it on the remote server.

The second script is executed on the remote server, as I said, where it will kill the java -jar nixmashSpring.war process and launch the War file we just copied in a background process.

Here’s what the two scripts look like when run in the console.

The second script executed in a remote terminal session.

One less deployment process we have to think about, which is always a good thing.