views:

470

answers:

4

I need to create some way to get a local WAR file deployed on a linux server. What I have been doing until now is the following process:

Upload WAR using WinSCP.
SSH into server using Putty.
Move/Rename/Delete certain files folders to prepare for WAR explosion.
Explode WAR.
Send email notifying users of restart.
Stop tomcat server.
Use tail to make sure server stopped correctly.
Change symlink to point to exploded WAR.
Start tomcat.
Use tail to make sure server started correctly.
Send email notifying users of completed restart.

This stuff is all relatively straightforward. And I'm sure there are a million and one different ways to do it. Id like to hear about some options. My first thought was a bash script. I have very little experience with scripting in general but thought this would be a good way to learn. I would also be interested in doing this with Ruby/Python or something current like this as I have little to no experience with these languages. I think as a young developer, I should definitely get some sort of scripting language under my belt. I may also be interested in some sort of software solution that could do this stuff for me, although I think scripting would be a better way to go for the sake of ease and customizability (I might have just made that word up).

Some actual questions for those that made it this far. What language would you recommend to automate the process I've listed above? Would this be a good opportunity for me to learn Bash/Ruby/Python/something else, or should I simply take the 10 minutes to do this by hand 2-3 times a week? I would think the answer to this is obviously no. Can I automate these things from my computer, or will I need to setup the scripts to run within the linux server? Is the email something I can automate or am I better off doing that part myself?

More questions will almost certainly come up as I do this so thanks to all in advance.

----UPDATE----
I should mention, I am using Maven to build the WAR. So if I can do all of this with Maven please let me know.

+3  A: 

This might be too heavy duty for your needs, but have you looked at build automation tools such as CruiseControl or Hudson? You might also want to look at Integrity, which is more lightweight and written in Ruby (instead of Java like the other two I mentioned). These tools can do everything you said you needed in your question plus way, way more.

Edit

Since you want this to be more of a learning exercise in scripting languages than a practical solution, here's an idea for you. Instead of manually uploading your WAR each time to your server, set up a Mercurial repository on your server and create a hook (see here, here, and especially here) that executes a Ruby (or ant, or maven) script each time a changeset is pushed from a remote computer (i.e. your local workstation). You would write the script so it does all the action items in your list above. That way, you will get to learn three new things: a distributed version control paradigm, how to customize said tool, and how to write Ruby scripts to interact with your operating system (since your actions are very filesystem heavy).

Marc W
I have looked into CruiseControl. I will look into the others you have mentioned, so thanks for those. I'm open to using software to do this, however I would like to avoid it if possible. I would prefer spending the time to learn a scripting language rather then spending the time learning to use software. If my deployment routine becomes more complex, I will certainly spend the time to further investigate the tools you mentioned.
UmYeah
Hudson is way easier to setup than CruiseControl. Since this is more of a learning experience for you and not a practical necessity, I'll add an additional suggestion to my answer.
Marc W
That edit looks great and is exactly what I am interested in. It looks like for now I will start using Hudson so some actual work can get done. But that 'learning exercise' is certainly something I will keep in mind when I have some time for it.
UmYeah
CC machines are a pain to setup. I would strongly suggest Hudson over CC as a learning exercise.
Nick Presta
+2  A: 

The most common in my experience is ant, it's worth learning, it's all pretty simple, and very usefull.

You should definately automate it, and you should aim to have it happen in 1 step.

Paul Creasey
A: 

What are you using to build the WAR file itself? There's some advantage to using the same tool for build and deployment. On several projects I've used Ant to build a Java project and deploy it to the servers.

Don Kirkby
A: 

Thank you all for your answers. I did not in any way try to spam the group, or hide the fact that Nolio is a commercial company (does not make us bad by default). Having said that, here is an overview of what Nolio does, and why I think that it's a great solution.

The workflow that UmYeah describes can be created in Nolio using a simple drag-and-drop interface, with very limited scripting and programming skills. This will take about 15-20 minutes. The workflow in Nolio is created independently from the environment, so it can be run on any physical, virtual, or cloud server.

There are many other benefits once the workflow is in Nolio. For example:

  1. other employees can run the process that was created by a technical person, without needing access to the servers.
  2. every change, run process, result, is saved and be reported on later
  3. if the workflow (not in UmYeah's case) needs to run on multi-tiers with dependencies between them (i.e.: restart tomcat only after db server was updated), this is also supported by Nolio

As I mentioned in my original post, I pushed for a free version of Nolio (must be my heavy open source background). I can be contacted for more details.

Again, I apologize if my first post was considered spam, self-promotion, or not in the spirit of the group, I just think that we have a really cool product that can take the grunt work out of so many peoples lives.

Cheers, Daniel noliosoft.com

Daniel Kushner