Add to build.gradle (!IMPORTANT, add probably at the end of the file, after 'apply'):
springBoot {
// Enable the creation of a fully
// executable archive file.
executable = true
}
start build the war:
$ grails assemble
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:findMainClass
:buildProperties UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileGsonViews UP-TO-DATE
:war
:bootRepackage
:assemble
BUILD SUCCESSFUL
Total time: 12.852 secs
| Built application to build/libs using environment: production
Then, create a new file in the same folder, with the same name as the war but give it .conf extension:
$ echo "" > myapp.conf
Open the newly created file and add this config Reference :
The MODE parameter is important! this config will allow our app to run on port 9999 and different environment. Change as you like.
MODE=service
JAVA_OPTS=-Dgrails.env=prod
RUN_ARGS=--server.port=9999
LOG_FOLDER=logs
PID_FOLDER=pid
Change the .war to .jar (Optional)
mv myaspp.war myaspp.jar
Create 2 new folder, 'pid' and 'logs' (Optional, just remove in parameters in conf file to leave it to default)
mkdir pid
mkdir logs
Now, Copy all the files and folders to your target server / destination. make sure the folder structure is like below:
myapp-folder/
/myapp.jar
/myapp.conf
/pid
/logs
then, in your server, cd to the folder and start the app
./myapp.jar start
you can check for available commands:
./myapp.jar
Usage: ./myapp.jar {start|stop|force-stop|restart|force-reload|status|run}
Thank you for reading.