perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.64k stars 1.56k forks source link

What is the recommended way of deploying a Sparkjava app? #979

Closed p-h closed 6 years ago

p-h commented 6 years ago

The docs don't talk much about what a deployment environment would look like, except for this. How would I, for example, go about deploying a Sparkjava app on a classic on premise Ubuntu server? Do I need an Application Server? Do I copy an uber jar to the server and write systemd unit file?

tipsy commented 6 years ago

Just create a jar with dependencies and run it as any other jar (java -jar file). There is a tutorial on the web page for deploying to Heroku.

p-h commented 6 years ago

This? I don't know how this applies to people not deploying on Heroku. Some people are still stuck in the mid 2000's when it comes to those things.

tipsy commented 6 years ago

It's the same procedure more or less anywhere. Just build a fat jar and run it.

dbrezack commented 6 years ago

Either you run it as java -jar myServer.jar or you can setup spark to run on something like a Tomcat server if you setup a tomcat server you can also setup gradle/maven to build the project as a war. Its even possible to configure both if you want to run a local and deployment based versions,

p-h commented 6 years ago

So do you ssh into your server, java -jar myApp.jar, and hope that the ssh connection doesn't crash? That the app doesn't crash and doesn't need to be restarted?

jakaarl commented 6 years ago

@p-h I think the question is more deployment environment than Spark specific. If you deploy as a runnable JAR, you should write a service wrapper (quick googling turned up for example this: https://dzone.com/articles/run-your-java-application-as-a-service-on-ubuntu). I guess daemontools and/or supervise would also be worth looking into.

p-h commented 6 years ago

@jakaarl Thank you, that's what I was looking for. 👍