diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-01-13 16:47:29 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-01-13 16:47:29 +0100 |
commit | 6c5aaabe8bb0ae1b8025953f6a9c462846bbb873 (patch) | |
tree | 93f68b2d3307b8f64187444a769a92cebf135caa /lib/capistrano/tasks | |
parent | 97130af8dd3f761bbc4cc085def3cd39b80b876e (diff) | |
parent | 00e2586a42931567d2ac18350d41dd882e7fcd92 (diff) | |
download | hmnoweb-6c5aaabe8bb0ae1b8025953f6a9c462846bbb873.tar.gz hmnoweb-6c5aaabe8bb0ae1b8025953f6a9c462846bbb873.tar.bz2 hmnoweb-6c5aaabe8bb0ae1b8025953f6a9c462846bbb873.zip |
Merge branch 'gallery-links'
Diffstat (limited to 'lib/capistrano/tasks')
-rw-r--r-- | lib/capistrano/tasks/configure_piwik.rake | 2 | ||||
-rw-r--r-- | lib/capistrano/tasks/configure_puma.rake | 15 | ||||
-rw-r--r-- | lib/capistrano/tasks/deploy_cold.rake | 42 |
3 files changed, 58 insertions, 1 deletions
diff --git a/lib/capistrano/tasks/configure_piwik.rake b/lib/capistrano/tasks/configure_piwik.rake index 99c42bb..d503cb0 100644 --- a/lib/capistrano/tasks/configure_piwik.rake +++ b/lib/capistrano/tasks/configure_piwik.rake @@ -7,7 +7,7 @@ namespace :deploy do on roles(:app) do unless test "[ -f #{output_file} ]" conf = { - fetch(:rails_env) => { + fetch(:stage) => { 'piwik' => { 'id_site' => fetch(:piwik_site_id), 'url' => fetch(:piwik_url), diff --git a/lib/capistrano/tasks/configure_puma.rake b/lib/capistrano/tasks/configure_puma.rake new file mode 100644 index 0000000..ccea36b --- /dev/null +++ b/lib/capistrano/tasks/configure_puma.rake @@ -0,0 +1,15 @@ +# :mode=ruby: +namespace :deploy do + desc 'Configure Puma' + task :configure_puma do + target_file = File.join(shared_path, 'config', 'puma.rb') + on roles(:app) do + unless test "[ -f #{target_file} ]" + template = ERB.new(IO.read(File.join(Dir.pwd, 'config', 'deploy', 'templates', 'puma.rb.erb'))) + upload!(StringIO.new(template.result(binding)), target_file) + end + end + end + + before 'deploy:finishing', 'deploy:generate_secret_token' +end diff --git a/lib/capistrano/tasks/deploy_cold.rake b/lib/capistrano/tasks/deploy_cold.rake new file mode 100644 index 0000000..f91ede6 --- /dev/null +++ b/lib/capistrano/tasks/deploy_cold.rake @@ -0,0 +1,42 @@ +# Capistrano task for cold deploys +# +# Taken from: https://stackoverflow.com/a/28001351/270280 +# Licensed under cc by-sa 3.0 +# +# Generalized and fixed running with the correct environment +# by Harald Eilertsen +# +namespace :deploy do + + # + # Run this for first time deploy (after setting up the database.) It + # loads the checked in schema instead of running through all the + # migrations to rebuild the database schema. + # + # The task will be skipped if the database schema already exists, and + # let the migrations run as normally. + # + + desc "deploy app for the first time (expects pre-created but empty DB)" + task :cold do + before 'deploy:migrate', 'deploy:initdb' + invoke 'deploy' + end + + desc "initialize a brand-new database (db:schema:load, db:seed)" + task :initdb => [ :set_rails_env ] do + on primary :db do |host| + within release_path do + if test(:psql, %Q{#{fetch(:pg_database)} -U #{fetch(:pg_user)} -c "SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE';"|grep schema_migrations}) + puts '*** THE PRODUCTION DATABASE IS ALREADY INITIALIZED, YOU IDIOT! ***' + else + with rails_env: fetch(:rails_env) do + execute :rake, 'db:schema:load' + execute :rake, 'db:seed' + end + end + end + end + end + +end |