[chef] Re: Re: Re: Deploying .war files?


Chronological Thread 
  • From: Haim Ashkenazi < >
  • To:
  • Subject: [chef] Re: Re: Re: Deploying .war files?
  • Date: Tue, 21 Jun 2011 07:04:51 +0300
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=kIXwIY4hjTMAJ//Tpfn3RMlAghg5qZaqKfuu9/eZafIjYBSESNTff09U8IpTDUYC8M L4rLc4qGWpJ3k3QxaCGo7PV4FG/nCeRY1DqQ8V8x/e9oVhvZRv30vA+cmz6IdIsSPb+Z xTX2OR4LjkMSfHPG9gL7rjieTVv9fmj1Pw56s=

Hi

On Tue, Jun 21, 2011 at 6:35 AM, Ken Mazaika < "> > wrote:
could you use something like capistrano for java?
I actually used capistrano to deploy wars to tomcat. It only took a couple of hours to create a custom capfile. I used the following procedure:
  • Used the tomcat api to uninstall the war (so it'll remove all the working temp files as well). something like:
def run_undeploy_command context
  run "curl -s --user #{tomcat_user}:#{tomcat_password} http://localhost:8080/manager/undeploy?path=/#{context}" do |c, s, d|
    raise %{Cannot undeploy #{context} => "#{d}"} unless d.start_with? "OK"
  end
end
  • Stopped tomcat
  • Copied the new war to the webapps directory
  • Started tomcat
This was a server where chef was not running as a service so I didn't have to worry about chef starting tomcat in while I'm copying the war. You can copy the war and then restart tomcat. Another option would be to use the api to deploy the new war and then restart tomcat (the reason I'm always restarting tomcat is to avoid PermGen memory errors).

HTH



On Mon, Jun 20, 2011 at 11:32 PM, Edward Sargisson < " target="_blank"> > wrote:
I need to do the same thing but haven't written it yet. Here's my plan
- hopefully others can critique.

Firstly, you don't want to stop tomcat. Chef runs every 20 minutes or
so (or whenever you set it for) so it would stop your server every 20
minutes. Instead, you should work out if the file on your file server
has changed and then do the update. In my case, my build artifacts
have a build id. I plan to store the desired build id in a data bag *.
The deployed data bag goes into the node data. Then, on the chef run
it can compare and then run the update if required.

When you do the update you don't need to stop tomcat. Instead you
download the WAR to a temp directory then go to the webapps dir and
delete the directory for your webapp as well as the old WAR. Then you
copy the WAR in. (You can't download directly because then Tomcat
un-jars it before it's downloaded). Tomcat then un-jars it and starts
it up for you.

Cheers,
Edward

* Amusingly, I forgot the name for data bag and my mind came up with
drop bag. Once a trail runner, always a trail runner... :-)

On Mon, Jun 20, 2011 at 8:25 PM,  < " target="_blank"> > wrote:
> Hi everyone,
> I'm fairly new to Chef. I downloaded and deployed the tomcat cookbook to a
> node, and now I'm trying to add a recipe? or another cookbook, I'm not sure
> really...to deploy our web app that should run on Tomcat.
>
> I basically want the node to stop tomcat, delete everything in the webapps
> directory, and scp a file to the right spot..then start tomcat.
>
> I looked briefly at the deploy resource, but that's from a version control
> system...we don't keep builds in version control, only the source..the binary
> builds are on a server, so I don't think that's what I want.
>
> If anyone can point me in the right direction to get this going, that would be
> greatly appreciated.
>
> Thanks.
>
> -Matt
>




--
Haim



Archive powered by MHonArc 2.6.16.

§