Everytime I deploy my grails app I do the same steps over and over again:
- get the latest build from our Hudson CI
- extract the war file from the CI archive
- scp the war to a gateway server
- scp the war to the target server
- run stop.sh to shutdown the jetty
- run update.sh to update the web app in the jetty webapps dir
- run start.sh to start the jetty
Reading the Productive Programmer I thought: “This should be automated”. Looking at the Rails world I found a tool named Capistrano which looked like a script library for deploying Rails apps. Using builders in groovy and JSch for SSH/scp I wrote a small script to do the tedious work using a self defined DSL for deploying grails apps:
Grapes grapes = new Grapes() def script = grapes.script { set gateway: "gateway-server" set username: "schneide" set password: "************" set project: "my_ci_project" set ciType: "hudson" set target: "deploy_target.com" set ci_server: "hudson-schneide" set files: ["webapp.war"] task("deploy") { grab from: "ci" scp to: "target" ssh "stop.sh" ssh "update.sh" ssh "start.sh" } } script.tasks.deploy.execute()
This is far from being finished but a starting point and I think about open sourcing it. What do you think: may it help you? What are your experiences with deploying grails apps?
i think that’s a great idea. I’ve been toying with the idea of using capistrano and webistrano for doing war deployments, but unfortunetely that is not my call at my job.
Having something like this in Groovy though would be awesome. I can just give out the script to somebody in Ops and they would run this.
Having passwords in there is a no-go for operations …keep that in mind. It will have to work with key based authentication. But other than that this sounds interesting.
I use jetty but I use hotdeploy to not stop container every deploy you do.
It works very well with grails 1.0.4 not with the previous versions
http://dahernan.net/2008/06/script-to-deploy-grails-applications.html
A pending task is doing with hudson 😀