7

I wonder if there is a tool which creates a demoable version of my grails projects. Something which I can distribute on a CD or USB stick which will run on every environment.

Something which

  • comes with one shell script to start the app
  • searches for a free server port on the system (no error message if 8080 is already in use)
  • starts a jetty server
  • starts the standard browser with my application

Does anybody know of such a tool?

rdmueller
  • 10,742
  • 10
  • 69
  • 126
  • Are you assuming you have the needed JVM on the target machine already, or are you looking for a true stand-alone server application? – cdeszaq May 03 '12 at 12:45
  • a true standalone app would be great, but I guess assuming that a JVM is already available is ok. – rdmueller May 03 '12 at 14:20

3 Answers3

15

Check out the standalone plugin it makes it a lot easier to distribute a demo version of your Grails app.

"The Standalone plugin builds a runnable JAR file with an embedded war built from your application and an embedded Tomcat 7 instance. This allows you to build a single archive that can be run on any computer with Java 5 or higher by running java -jar standalone.jar. This can be convenient for demos or even very lightweight installs of low-traffic Grails applications."

Full docs for the standalone plugin are here

To prepare the jar file...

grails -Dgrails.env=demo build-standalone our_cool_demo.jar

To run the Grails app (the port is specified as a parameter)...

java -jar /path/to/jar_name.jar cool_demo localhost 9000


Update:

There are actually 2 Grails standalone plugins:

  1. The 'standalone' plugin described above which is based on Tomcat7
  2. The 'jetty-standalone' plugin which is based on Jetty and works in a similar way

There are also some options based on Hudson and the Winstone project but there isn't a Grails plugin. Here are some links with further information: Build executable war using grails, maven and jetty, Executable WARs with Jetty and Winstone

bmaupin
  • 14,427
  • 5
  • 89
  • 94
Chris
  • 3,552
  • 2
  • 26
  • 36
  • 1
    there's also another standalone plugin based on jetty which may work. See the updated answer above for more info. – Chris Apr 30 '12 at 07:52
  • please see my answer down below, too. Both plugins do not work for me, but are a good starting point. – rdmueller May 25 '12 at 05:09
  • 1
    I have used both plugins successfully but was also unable to get them working with some projects. I'm guessing it depends on the project complexity, dependencies and plugins used. – Chris May 25 '12 at 08:01
  • 1
    the standalone-plugin just got an update. So all problems should be fixed by now. will give it a try and report back. – rdmueller Aug 07 '12 at 07:53
  • @Chris : hi , i am having a little prob to understand all this stuff , could you please be available to describe a little more to me – Hussain Akhtar Wahid 'Ghouri' May 15 '13 at 09:14
  • Can someone explain why it's only suited for low-traffic applications? – Ms01 Aug 02 '14 at 19:16
2

Best thing that comes to mind is using a Linux distro on a USB stick with grails installed. You can export the application as a WAR file, then create a script containing grails prod run-war to execute on boot. Finally, you can open up firefox with firefox localhost:port#/AppName

The only downside with this option is you need to boot from the stick and that will create a bit of delay time. However, the advantages are that you only have to worry about supporting one OS, no port scanning on startup and simplicity.

Jason
  • 11,263
  • 21
  • 87
  • 181
1

The answer proposed by Chris does not work for my, but it provided me a good starting point: It seems that it isn't too hard to create such a standalone app:

  • jetty is a good starting point: just drop the jetty files on a USB stick and deploy your grails app by dropping the .war file in the webapps directory of jetty
  • create a small groovy script which searches for two (!) free ports. You'll need the second to stop the server again
  • the groovy script can start and stop the server
  • compile the script in order to avoid having to install groovy on the target machine

that's it. I guess I'll post more details when I find some more time...

rdmueller
  • 10,742
  • 10
  • 69
  • 126