I launch my Jar-based websites with a bash script, and I like to do it manually. Sometimes, however your cloud provider might need to perform scheduled maintenance and reboot your server at 3:00 AM or some ridiculous hour. In those instances it's nice to be able to launch your websites automatically on Server Startup rather than get up in the middle of the night.
When you break down the process, all we're doing is launching a batch file on Server Startup...with a caveat which we'll get to. There are several ways to do this in Linux. This AskUbuntu Post does a good job of describing three of them.
We're going to simply add our website bash script to our /etc/rc.local file. Before we do let's look at the bash script that launches our Fat Jar.
That bash script is located in /home/daveburke/startupMyApp.sh. Here we're adding it to our /etc/rc.local file.
Remember I said there might be a caveat with adding a script to our rc.local file? Here it is. We need to launch the website Jar as the User who normally launches it if not root. That's where the -u daveburke in the rc.local update comes into play. If we don't do that we'll see Server 500 Exceptions across the board.