Guest User

Untitled

a guest
Mar 12th, 2018
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1.  
  2.  
  3. # =============================================================================
  4. # TASKS
  5. # =============================================================================
  6. # Define tasks that run on all (or only some) of the machines. You can specify
  7. # a role (or set of roles) that each task should be executed on. You can also
  8. # narrow the set of servers to a subset of a role by specifying options, which
  9. # must match the options given for the servers to select (like :primary => true)
  10.  
  11.  
  12.  
  13.  
  14.  
  15. desc "Mongrel deployment - stops server, backs up sqlite db, updates code from svn, copies db back, migrates, starts mongrel"
  16. task :deploy_me, :roles => :app do
  17. stop
  18. #backup_db
  19. update_code
  20. symlink
  21. migrate
  22. start
  23. end
  24.  
  25.  
  26. task :import_data do
  27. run "cd #{deploy_to}/#{current_dir} && rake RAILS_ENV='production' db:import"
  28. end
  29.  
  30.  
  31. task :layout do
  32. run "svn cat svn://apptest.uwec.edu/webdev/app065/trunk/app/views/layouts/public.rhtml > #{deploy_to}/#{current_dir}/app/views/layouts/public.rhtml"
  33.  
  34.  
  35.  
  36. end
  37.  
  38.  
  39. desc "bumps mongrel"
  40. task :restart do
  41. stop
  42. start
  43.  
  44. end
  45.  
  46. desc "mongrel_start"
  47. task :start do
  48. send(run_method, "cd #{deploy_to}/#{current_dir} && mongrel_rails start -e production -p #{mongrel_port} -d")
  49. end
  50.  
  51. task :stop do
  52. desc "mongrel stop"
  53. run "rm -rf #{deploy_to}/#{current_dir}/logs/mongrel*"
  54. send(run_method, "cd #{deploy_to}/#{current_dir} && mongrel_rails stop") rescue nil
  55. end
  56.  
  57.  
  58.  
  59. desc "Create database.yml in shared/config"
  60. task :after_setup do
  61.  
  62. database_configuration = render :template => <<-EOF
  63. production:
  64. database: <%= "app065rails_production" %>
  65. adapter: sqlserver
  66. mode:odbc
  67. dsn: <%= dsn %>
  68. username: <%= dbuser %>
  69. password: <%= dbpassword %>
  70. EOF
  71.  
  72. run "mkdir -p #{deploy_to}/#{shared_dir}/config"
  73. put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
  74.  
  75. create_config_file
  76. end
  77.  
  78.  
  79. desc "Create configuration yaml file"
  80. task :create_config_file do
  81.  
  82. config = render :template => <<EOF
  83. production:
  84. email:
  85. server: smtp.uwec.edu
  86. port: 25
  87. domain: uwec.edu
  88. authentication: none
  89. username:
  90. password:
  91. contact_recipient: pickarpr@uwec.edu
  92. content_type: text/html
  93. EOF
  94. run "mkdir -p #{deploy_to}/#{shared_dir}/config"
  95. put config, "#{deploy_to}/#{shared_dir}/config/config.yml"
  96.  
  97.  
  98.  
  99. end
  100.  
  101.  
  102. desc "sets perms on root, links database file, and links rails"
  103. task :after_update_code, :roles => [:web, :db, :app] do
  104. run "chmod 755 #{release_path}/public -R"
  105. run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
  106. run "rm -f #{release_path}/config/config.yml" # removes the checked-out config file rescue nil
  107. run "ln -nfs #{deploy_to}/#{shared_dir}/config/config.yml #{release_path}/config/config.yml"
  108. #run "ln -nfs #{root_path}/rails123 #{release_path}/vendor/rails"
  109. end
  110.  
  111. desc "backup the MDH database"
  112. task :backup_db do
  113. # the on_rollback handler is only executed if this task is executed within
  114. # a transaction (see below), AND it or a subsequent task fails.
  115. on_rollback { delete "/tmp/dump.sql" }
  116.  
  117. run "mysqldump -u #{dbuser} -p #{dbpassword} > #{db_filename}" do |ch, stream, out|
  118. ch.send_data "#{dbpassword}\n" if out =~ /^Enter password:/
  119. end
  120. end
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. ####### Portion of output ##########
  130.  
  131. * executing task stop
  132. * executing "rm -rf /app/app065/current/logs/mongrel*"
  133. servers: ["frisbee.lts.uwec.edu"]
  134. [frisbee.lts.uwec.edu] executing command
  135. command finished
  136. * executing "cd /app/app065/current && mongrel_rails stop"
  137. servers: ["frisbee.lts.uwec.edu"]
  138. [frisbee.lts.uwec.edu] executing command
  139. ** [out :: frisbee.lts.uwec.edu] Sending TERM to Mongrel at PID 28116...Process does not exist. Not running.
  140. ** [out :: frisbee.lts.uwec.edu] Done.
  141. command finished
  142. * executing task start
  143. * executing "cd /app/app065/current && mongrel_rails start -e production -p 5065 -d"
  144. servers: ["frisbee.lts.uwec.edu"]
  145. [frisbee.lts.uwec.edu] executing command
  146. ** [out :: frisbee.lts.uwec.edu] **
  147. ** [out :: frisbee.lts.uwec.edu] !!! PID file log/mongrel.pid already exists. Mongrel could be running already. Check your log/mongrel.log for errors.
  148. ** [out :: frisbee.lts.uwec.edu] **
  149. ** [out :: frisbee.lts.uwec.edu] !!! Exiting with error. You must stop mongrel and clear the .pid before I'll attempt a start.
  150. command finished
  151. command "cd /app/app065/current && mongrel_rails start -e production -p 5065 -d" failed on frisbee.lts.uwec.edu
Add Comment
Please, Sign In to add comment