1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Attempt to use foreman to export init script.

This commit is contained in:
Daniel Barber 2015-08-19 12:17:25 +01:00
parent 46c31f04ce
commit 16a8f57be7
3 changed files with 52 additions and 15 deletions

View File

@ -24,7 +24,6 @@ gem 'capistrano'
gem 'capistrano-rbenv' gem 'capistrano-rbenv'
gem 'capistrano-bundler' gem 'capistrano-bundler'
gem 'capistrano-rails' gem 'capistrano-rails'
gem 'capistrano-foreman'
# To use debugger # To use debugger
# gem 'ruby-debug' # gem 'ruby-debug'
@ -65,13 +64,15 @@ group :test do
end end
group :production do group :production do
gem 'foreman'
gem 'puma' gem 'puma'
gem 'rails_12factor' gem 'rails_12factor'
end end
gem 'newrelic_rpm' gem 'newrelic_rpm'
gem 'foreman'
gem 'foreman-export-initscript'
gem 'pg' gem 'pg'
gem 'devise' gem 'devise'
gem 'simple_form' gem 'simple_form'

View File

@ -53,9 +53,6 @@ GEM
capistrano-bundler (1.1.4) capistrano-bundler (1.1.4)
capistrano (~> 3.1) capistrano (~> 3.1)
sshkit (~> 1.2) sshkit (~> 1.2)
capistrano-foreman (1.2.0)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rails (1.1.3) capistrano-rails (1.1.3)
capistrano (~> 3.1) capistrano (~> 3.1)
capistrano-bundler (~> 1.1) capistrano-bundler (~> 1.1)
@ -132,6 +129,8 @@ GEM
nokogiri (~> 1.5, >= 1.5.11) nokogiri (~> 1.5, >= 1.5.11)
foreman (0.78.0) foreman (0.78.0)
thor (~> 0.19.1) thor (~> 0.19.1)
foreman-export-initscript (0.0.1)
foreman
formatador (0.2.5) formatador (0.2.5)
haml (4.0.7) haml (4.0.7)
tilt tilt
@ -292,7 +291,6 @@ DEPENDENCIES
bourbon bourbon
capistrano capistrano
capistrano-bundler capistrano-bundler
capistrano-foreman
capistrano-rails capistrano-rails
capistrano-rbenv capistrano-rbenv
capybara-screenshot capybara-screenshot
@ -305,6 +303,7 @@ DEPENDENCIES
factory_girl_rails factory_girl_rails
fivemat fivemat
foreman foreman
foreman-export-initscript
haml haml
hpricot hpricot
jquery-rails jquery-rails

View File

@ -1,3 +1,5 @@
require 'capistrano/foreman'
# config valid only for current version of Capistrano # config valid only for current version of Capistrano
lock '3.4.0' lock '3.4.0'
@ -37,15 +39,6 @@ set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', '
set :rbenv_type, :user set :rbenv_type, :user
set :rbenv_ruby, '2.2.1' set :rbenv_ruby, '2.2.1'
set :foreman_use_sudo, false # Set to :rbenv for rbenv sudo, :rvm for rvmsudo or true for normal sudo
set :foreman_roles, :all
set :foreman_template, 'systemd'
set :foreman_export_path, File.join(Dir.home, '.init')
set :foreman_options, {
app: application,
log: File.join(shared_path, 'log')
}
namespace :deploy do namespace :deploy do
after :restart, :clear_cache do after :restart, :clear_cache do
@ -58,3 +51,47 @@ namespace :deploy do
end end
end end
namespace :foreman do
desc 'Export the Procfile to Debian systemd scripts'
task :export do
on roles(:app) do |host|
log_path = shared_path.join('log')
environment_path = fetch(:foreman_env)
within release_path do
as :root do
execute :sudo, "foreman export initscript /etc/init.d/ -a #{fetch(:application)} -u #{host.user} -l #{log_path} -e #{environment_path}"
end
end
end
end
desc 'Start the application services'
task :start do
on roles(:app) do |host|
as :root do
execute :start, fetch(:application)
end
end
end
desc 'Stop the application services'
task :stop do
on roles(:app) do |host|
as :root do
execute :stop, fetch(:application)
end
end
end
desc 'Restart the application services'
task :restart do
on roles(:app) do |host|
as :root do
execute :service, "#{fetch(:application)} start || service #{fetch(:application)} restart"
end
end
end
before 'deploy:publishing', 'foreman:export'
end