Skip to content

Instantly share code, notes, and snippets.

@kuntoaji
Created August 8, 2015 17:57
Show Gist options
  • Save kuntoaji/4b25c5d89aea90c8cc48 to your computer and use it in GitHub Desktop.
Save kuntoaji/4b25c5d89aea90c8cc48 to your computer and use it in GitHub Desktop.
Discourse Configuration
# config/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
set :term_mode, nil
set :rails_env, 'production'
set :domain, 'example.com'
set :deploy_to, '/home/myexampleuser/apps/discourse'
set :repository, '[email protected]:discourse/discourse.git'
set :branch, 'master'
set :shared_paths, ['config/discourse.conf', 'log', 'public/uploads', 'public/backups', 'tmp/pids']
set :user, 'myexampleuser' # Username in the server to SSH to.
set :forward_agent, true # SSH forward_agent.
task :environment do
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/discourse.conf"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/public/uploads"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/public/backups"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/public/uploads"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/public/backups"]
queue! %[mkdir -p "#{deploy_to}/tmp/pids"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/tmp/pids"]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
to :launch do
# uncomment if you want restart thin and on deploy
#invoke :'sidekiq:restart'
#invoke :'thin:restart'
end
end
end
namespace :thin do
desc "start thin server"
task :start => :environment do
queue "cd #{deploy_to}/#{current_path}/ && RUBY_GC_MALLOC_LIMIT=25000000 bundle exec thin -C config/thin.yml start"
end
desc "stop thin server"
task :stop => :environment do
queue "cd #{deploy_to}/#{current_path}/ && RUBY_GC_MALLOC_LIMIT=25000000 bundle exec thin -C config/thin.yml stop"
end
desc "restart thin server"
task :restart => :environment do
queue "cd #{deploy_to}/#{current_path}/ && RUBY_GC_MALLOC_LIMIT=25000000 bundle exec thin -C config/thin.yml restart"
end
end
namespace :sidekiq do
desc "start sidekiq"
task :start => :environment do
queue "cd #{deploy_to}/#{current_path}/ && bundle exec sidekiq -C config/sidekiq.yml -e production"
end
desc "stop sidekiq"
task :stop => :environment do
queue "cd #{deploy_to}/#{current_path}/ && bundle exec sidekiqctl stop /home/myexampleuser/apps/discourse/tmp/pids/sidekiq.pid"
end
desc "restart sidekiq"
task :restart => :environment do
invoke :'sidekiq:stop'
invoke :'sidekiq:start'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment