Skip to content
Browse files

task to configure and start the websocket

Signed-off-by: David A. Cuadrado <krawek@gmail.com>
  • Loading branch information...
1 parent 88e7e25 commit c875935c2aaae1a8650385d644173e6e90005304 @dcu dcu committed
Showing with 47 additions and 0 deletions.
  1. +5 −0 INSTALL_ON_PRODUCTION
  2. +6 −0 config/deploy.rb.sample
  3. +36 −0 config/pills/websocket.pill.erb
View
5 INSTALL_ON_PRODUCTION
@@ -58,5 +58,10 @@ app ALL=(ALL) NOPASSWD: ALL
7. Deploy
$ cap production bootstrap
$ cap production bluepill:init
+ $ cap production magent:setup
$ cap production magent:init
+
+ $ cap production websocket:setup
+ $ cap production websocket:init
+
$ cap production deploy
View
6 config/deploy.rb.sample
@@ -14,6 +14,7 @@ end
namespace :deploy do
task :restart, :roles => :app, :except => { :no_release => true } do
run "echo '#{`git describe`}' > #{current_path}/public/version.txt"
+ run "cd #{current_path} && ln -sf #{shared_path}/config/auth_providers.yml #{current_path}/config/auth_providers.yml"
assets.compass
assets.package
@@ -29,6 +30,11 @@ require 'ricodigo_capistrano_recipes'
set(:websocket_remote_config) { "#{shared_path}/config/pills/websocket.pill"}
namespace :websocket do
+ desc "setup websocket pill"
+ task :setup do
+ generate_config("#{File.dirname(__FILE__)}/pills/websocket.pill.erb", websocket_remote_config)
+ end
+
desc "Init websocket with bluepill"
task :init do
rvmsudo "bluepill load #{websocket_remote_config}"
View
36 config/pills/websocket.pill.erb
@@ -0,0 +1,36 @@
+app_name = 'websocket'
+grace_time = 120
+rails_root = '<%= "#{deploy_to}/current" %>'
+rails_env = '<%= environment %>'
+log_file = "#{rails_root}/log/#{app_name}_bluepill.log"
+cmd_bin = "/usr/bin/env RAILS_ENV=#{rails_env} bundle exec script/#{app_name}"
+cmd_pid = "#{rails_root}/tmp/pids/#{app_name}.pid"
+
+cmd_start_cmd = "#{cmd_bin}"
+cmd_stop_cmd = "kill -9 {{PID}}"
+cmd_restart_cmd = "bash -c '#{cmd_stop_cmd} && #{cmd_start_cmd}'"
+
+
+puts ">> Starting #{app_name} bluepill with RAILS_ROOT=#{rails_root} and RAILS_ENV=#{rails_env}"
+
+Bluepill.application(app_name, :log_file => log_file) do |app|
+ app.process("cmd-#{app_name}") do |process|
+ process.pid_file = cmd_pid
+ process.daemonize = true
+ process.working_dir = rails_root
+
+ process.start_command = cmd_start_cmd
+ process.stop_command = cmd_stop_cmd
+ process.restart_command = cmd_restart_cmd
+
+ process.start_grace_time = grace_time
+ process.stop_grace_time = grace_time
+ process.restart_grace_time = grace_time
+
+ process.uid = "<%= user %>"
+ process.gid = "<%= group %>"
+
+ process.checks :mem_usage, :every => 15.seconds, :below => 165.megabytes, :times => [3,4], :fires => :stop
+ process.checks :cpu_usage, :every => 15.seconds, :below => 90, :times => [3,4], :fires => :stop
+ end
+end

0 comments on commit c875935

Please sign in to comment.
Something went wrong with that request. Please try again.