Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. require 'mina/bundler'
  2. require 'mina/rails'
  3. require 'mina/git'
  4. require 'mina/rvm'
  5.  
  6. set :user, 'root'
  7. set :domain, '111.111.111.111'
  8. set :deploy_to, '/home/rails/project-rails'
  9. set :repository, 'repository-git'
  10. set :shared_paths, ['config/database.yml', 'log', 'tmp', 'public/system']
  11. set :keep_releases, 2
  12. set :term_mode, nil
  13. set :forward_agent, true
  14. set :port, '22'
  15. set :branch, 'master'
  16. set :rails_env, 'production'
  17.  
  18. set :rvm_use_path, '/usr/local/rvm/scripts/rvm'
  19.  
  20. task :environment do
  21. invoke :'rvm:use', 'ruby-2.4.0'
  22. end
  23.  
  24. desc "Creates shared directories, set permissions, touches database.yml"
  25. task :setup do
  26. command %{mkdir -p "#{fetch(:deploy_to)}/shared/public/assets"}
  27. command %{mkdir -p "#{fetch(:deploy_to)}/shared/log"}
  28. command %{mkdir -p "#{fetch(:deploy_to)}/shared/tmp/pids"}
  29. command %{chmod g+rx,u+rwx "#{fetch(:deploy_to)}/shared/log"}
  30.  
  31. command %{mkdir -p "#{fetch(:deploy_to)}/shared/config"}
  32. command %{chmod g+rx,u+rwx "#{fetch(:deploy_to)}/shared/config"}
  33.  
  34. command %{touch "#{fetch(:deploy_to)}/shared/config/database.yml"}
  35. comment "Be sure to edit 'shared/config/database.yml'."
  36. end
  37.  
  38. desc "Deploys the current version to the server."
  39. task :deploy => :environment do
  40. invoke :environment
  41. deploy do
  42. invoke :'git:clone'
  43. invoke :'deploy:link_shared_paths'
  44. # in_path(fetch(:deploy_to)) do
  45. command %{ln -s "#{fetch(:deploy_to)}/shared/config/database.yml" "./config/database.yml"}
  46. command %{ln -s "#{fetch(:deploy_to)}/shared/config/secrets.yml" "./config/secrets.yml"}
  47. # end
  48. # command %{source "/usr/local/rvm/bin"}
  49. invoke :'bundle:install'
  50. invoke :'rails:db_migrate'
  51. invoke :'rails:assets_precompile'
  52. invoke :'deploy:cleanup'
  53. command %{chmod 777 -R #{fetch(:deploy_to)}/shared/tmp}
  54. command %{chmod 777 -R #{fetch(:deploy_to)}/shared/log}
  55. command %{chmod 777 -R #{fetch(:deploy_to)}/shared/public/system}
  56.  
  57. on :launch do
  58. invoke :restart
  59. end
  60. end
  61. end
  62.  
  63. task :restart do
  64.  
  65. # in_path(fetch(:current_path)) do
  66. command %{mkdir -p tmp/}
  67. command %{touch tmp/restart.txt}
  68. # end
  69.  
  70. end
  71.  
  72. task :setup_nginx do
  73. command "cp -r #{fetch(:deploy_to)}/current/evento-coletivo.conf /etc/nginx/conf/sites-enabled/"
  74. command "sudo service nginx restart"
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement