Skip to content

Instantly share code, notes, and snippets.

@universal
Last active February 27, 2019 03:56
Show Gist options
  • Save universal/6810849 to your computer and use it in GitHub Desktop.
Save universal/6810849 to your computer and use it in GitHub Desktop.
sample bluepill file with puma and sidekiq
Bluepill.application("gitlabhq", :foreground => false, :log_file => "/home/deploy/deploy/gitlabhq/shared/log/bluepill.log", :base_dir => "/home/deploy/.bluepill") do |app|
app.uid = "deploy"
app.gid = "deploy"
app.working_dir = "/home/deploy/deploy/gitlabhq/current"
app.process("web-1") do |process|
process.start_command = "puma -b unix:///home/deploy/deploy/gitlabhq/shared/puma.sock"
process.daemonize = true
process.environment = {"RAILS_ENV" => "production"}
process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
process.stop_grace_time = 45.seconds
process.stdout = process.stderr = "/home/deploy/deploy/gitlabhq/shared/log/gitlabhq-web-1.log"
process.monitor_children do |children|
children.stop_command "kill -QUIT {{PID}}"
end
process.group = "gitlabhq-web"
end
app.process("worker-1") do |process|
pid_file = "/home/deploy/deploy/gitlabhq/shared/pids/sidekiq-1.pid"
process.start_command = "bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitolite,common,default -P #{pid_file}"
process.pid_file = pid_file
process.daemonize = true
process.environment = {"RAILS_ENV" => "production"}
process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
process.stop_grace_time = 45.seconds
process.start_grace_time = 1.minute
process.stdout = process.stderr = "/home/deploy/deploy/gitlabhq/shared/log/gitlabhq-worker-1.log"
process.monitor_children do |children|
children.stop_command "bundle exec sidekiqctl stop #{pidfile}"
end
process.group = "gitlabhq-worker"
end
end
## head of deploy.rb
# rvm integration
set :rvm_type, :user
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, '1.9.3' # Or whatever env you want it to run in.
#set :bundle_flags, "--deployment --quiet --binstubs --shebang ruby-local-exec"
#bundler integration
require "bundler/capistrano"
load 'deploy/assets'
#whenever integration
set :whenever_command, defer {"bundle exec whenever -f #{shared_path}/config/#{stage}.schedule"}
set :whenever_environment, defer { rails_env }
set :whenever_identifier, defer { "#{application}_#{stage}" }
require "whenever/capistrano"
### bluepill stuff
def bp_command(sub_command)
"bluepill #{sub_command} --no-privileged --base-dir ~/.bluepill"
end
namespace :bluepill do
desc "Start the application services"
task :start do
run bp_command("load #{shared_path}/config/#{stage}.pill --logfile #{shared_path}/log/bluepill.log")
end
desc "Stop the application services"
task :stop do
run bp_command("#{application} stop")
end
desc "Restart the application services"
task :restart, :roles => :app do
bluepill.stop
bluepill.start
#run "cd #{current_path} && #{BP_BASE_CMD} #{stage} restart"
end
desc "Quit bluepill"
task :quit, :roles => :app do
run bp_command("#{application} quit")
end
desc "Log the application services"
task :log, :roles => :app do
run bp_command("#{application} log")
end
desc "Status of the application services"
task :status, :roles => :app do
run bp_command("#{application} status")
end
desc "Upload Config"
task :upload_config, :roles => :app do
upload "config/deploy/#{application}/#{stage}.pill", "#{shared_path}/config/#{stage}.pill"
end
end
# whenever reboot
every :reboot do
current_path = "/home/deploy/deploy/gitlabhq/current"
shared_path = "/home/deploy/deploy/gitlabhq/shared"
BP_BASE_CMD = "bluepill --no-privileged"
bp_cmd = "#{BP_BASE_CMD} --base-dir /home/deploy/.bluepill --logfile #{shared_path}/log/bluepill.log"
command "cd #{current_path} && #{bp_cmd} load #{shared_path}/config/gitlabhq.pill"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment