How do I make Chef wait for application deployment before moving files?

I have the following chef's recipe

aws_s3_file "/usr/share/tomcat/webapps/system.war" do
  bucket "mybucket"
  remote_path "builds/system_latest.war"
  aws_access_key_id node[:aws_access_key_id]
  aws_secret_access_key node[:aws_secret_access_key]
end

service "tomcat" do
  action [:restart]
end

aws_s3_file "/usr/share/tomcat/webapps/system/WEB-INF/application.properties" do
  bucket "mybucket"
  remote_path "config/application.properties"
  aws_access_key_id node[:aws_access_key_id]
  aws_secret_access_key node[:aws_secret_access_key]
end

      

It works fine every time I start it, except the machine is new.

When this is a new car I get:

Errno :: ENOENT ------------- No such file or directory - / usr / share / tomcat / webapps / system / WEB-INF / application.properties

I think this is because tomcat is not running when the application is deployed, so the folder does not exist when this statement is run.

I am assuming that moving files around the application during deployment is a common procedure. How can I do this and ensure that the boss waits until the deployment is complete?

+3


source to share


1 answer


Write some code (maybe in Ruby or Bash) to ask if Tomcat is done when you put it in a while loop.



ruby_block 'wait for tomcat' do
  block do
    true until ::File.exists?('/usr/share/tomcat/webapps/system/WEB-INF')
  end
end

      

+3


source







All Articles