capistrano-generals 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 444259204853e083167932e870acd97c4360b00f
4
- data.tar.gz: 78e81b15e2799d8e9328853fbf2859969ba821af
3
+ metadata.gz: d2c78daf4bc1e8479724fa3211de258e1f2f58bf
4
+ data.tar.gz: 03fd09d616010c7510d45a54cef2f9f4f8b4aad4
5
5
  SHA512:
6
- metadata.gz: e37ebac2df3d7812a98a550f8699a917cbc1e214406b7171f4613dda1c2378a4434eeb869ec8527f721ef0c027a1d7d532676744d42e5c585e955abe3e012e3c
7
- data.tar.gz: 57657a23a0a7c8c4d2a9d2d20621513c48083fb5c0ce8da6121b66a11eea9c85766c5d58f161fcb84c435e24b357f7b396dc0a88b1ad9aa4ae61f9486f47a2e0
6
+ metadata.gz: 265349e18ae429c85602f6b0bfa7c52efae03caa114efb2b38715dd0a7da099a8de17f4ab9a9b44503add542ac0760ca024cb05ecdf7b408bdd8669856d6156b
7
+ data.tar.gz: 235b15f72a9c27ec6fea6c1f6542d9252eb94d198753e568b986ac8948b6d6714ca3bf8b97bf9a926d40da4a5454a72fe2d5ce9cb5d65eb529088c95930280e9
@@ -0,0 +1,34 @@
1
+ module Capistrano
2
+ module DSL
3
+ module FayePaths
4
+
5
+ def faye_service
6
+ "faye_#{fetch(:app_config_name)}"
7
+ end
8
+
9
+ def faye_initd_file
10
+ "/etc/init.d/#{faye_service}"
11
+ end
12
+
13
+ def faye_default_config_file
14
+ shared_path.join('config/faye.ru')
15
+ end
16
+
17
+ def faye_default_pid_file
18
+ shared_path.join('tmp/pids/faye.pid')
19
+ end
20
+
21
+ def faye_default_require
22
+ current_path.join('config/environment')
23
+ end
24
+
25
+ def faye_log_dir
26
+ shared_path.join('log')
27
+ end
28
+
29
+ def faye_log_file
30
+ sidekiq_log_dir.join(fetch(:faye_log))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Generals
3
- VERSION = "0.1.10"
3
+ VERSION = "0.1.11"
4
4
  end
5
5
  end
@@ -74,7 +74,7 @@ namespace :load do
74
74
  # Puma Worker Killer settings
75
75
  set :puma_worker_killer_ram, 512 # mb
76
76
  set :puma_worker_killer_frequency, 10 #seconds
77
- set :puma_worker_killer_percent_usage, 0.99 # percent of RAM to use
77
+ set :puma_worker_killer_percent_usage, 0.95 # percent of RAM to use
78
78
  set :puma_worker_killer_rolling_restart_frequency, 6*3600 # 6 hours in seconds
79
79
 
80
80
  # General Sidekiq settings
@@ -83,6 +83,19 @@ namespace :load do
83
83
  set :sidekiq_pid, -> { sidekiq_default_pid_file }
84
84
  set :sidekiq_log, 'sidekiq.log'
85
85
 
86
+ # General Faye settings
87
+ set :faye_mount_location, '/faye'
88
+ set :faye_timeout, 25
89
+ set :faye_port, 9292
90
+ set :faye_extensions, []
91
+ set :faye_require, -> { faye_default_require }
92
+ set :faye_user, -> { fetch(:deploy_user) }
93
+ set :faye_pid, -> { faye_default_pid_file }
94
+ set :faye_log, 'faye.log'
95
+ set :faye_max_log_files, 3
96
+ set :faye_max_log_size, 100 # in mb
97
+ set :faye_config, -> { faye_default_config_file } # shared_path/config/faye.ru
98
+
86
99
  # Capistrano settings
87
100
  set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids')
88
101
  set :templates_path, 'config/deploy/templates'
@@ -0,0 +1,77 @@
1
+ require 'capistrano/dsl/faye_paths'
2
+ include Capistrano::DSL::FayePaths
3
+
4
+ namespace :faye do
5
+
6
+ desc 'Test capistrano config setup'
7
+ task :capistrano_config_test do
8
+ raise 'Faye is not on, use_faye is false' unless fetch(:use_faye)
9
+ end
10
+
11
+ desc 'Setup faye initializer'
12
+ task :setup_initializer do
13
+ on roles :app do
14
+ sudo_upload! template('faye_init.sh'), faye_initd_file
15
+ execute :chmod, '+x', faye_initd_file
16
+ sudo 'update-rc.d', '-f', faye_service, 'defaults'
17
+ end
18
+ end
19
+ before :setup_initializer, :capistrano_config_test
20
+
21
+ desc 'Setup faye app configuration'
22
+ task :setup_app_config do
23
+ on roles :app do
24
+ execute :mkdir, '-pv', File.dirname(fetch(:faye_config).to_s)
25
+ upload! template('faye.ru'), fetch(:faye_config).to_s
26
+ end
27
+ end
28
+ before :setup_app_config, :capistrano_config_test
29
+
30
+ desc 'Setup faye'
31
+ task :setup do
32
+ if fetch :use_faye
33
+ invoke 'faye:setup_initializer'
34
+ end
35
+ end
36
+
37
+ desc 'Start faye'
38
+ task :start do
39
+ on roles :app do
40
+ sudo faye_initd_file, 'start'
41
+ end
42
+ end
43
+ before :start, :capistrano_config_test
44
+
45
+ desc 'Stop faye'
46
+ task :stop do
47
+ on roles :app do
48
+ sudo faye_initd_file, 'stop'
49
+ sleep 8
50
+ end
51
+ end
52
+ before :stop, :capistrano_config_test
53
+
54
+ desc 'Restart faye'
55
+ task :restart do
56
+ invoke 'faye:stop'
57
+ invoke 'faye:start'
58
+ end
59
+ before :restart, :capistrano_config_test
60
+
61
+ desc 'Restarts faye if faye enabled'
62
+ task :after_publishing do
63
+ if fetch :use_faye
64
+ invoke 'faye:restart'
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ namespace :deploy do
71
+ after :publishing, 'faye:after_publishing'
72
+ end
73
+
74
+ desc 'Server setup tasks'
75
+ task :setup do
76
+ invoke 'faye:setup'
77
+ end
@@ -0,0 +1,12 @@
1
+ <%= template_to_s('_head').to_s %>
2
+ <% if fetch(:faye_require) %>
3
+ require '<%= fetch(:faye_require) %>'
4
+ <% end %>
5
+
6
+ Faye.logger = Logger.new('<%= faye_log_file %>', <%= fetch(:faye_max_log_files) %>, <%= fetch(:faye_max_log_size) %>*1e6) # Max 3 files of 100 MB
7
+
8
+ bayeux = Faye::RackAdapter.new mount: '<%= fetch(:faye_mount_location) %>', timeout: <%= fetch(:faye_timeout) %>
9
+ <% for extension in fetch(:faye_extensions) %>
10
+ bayeux.add_extension(<%= extension %>)
11
+ <% end %>
12
+ run bayeux
@@ -0,0 +1,63 @@
1
+ #!/bin/bash
2
+ <%= template_to_s('_head').to_s %>
3
+ ### BEGIN INIT INFO
4
+ # Provides: faye
5
+ # Required-Start: $remote_fs $syslog
6
+ # Required-Stop: $remote_fs $syslog
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: Manage faye server
10
+ # Description: Start, stop, restart faye server for a specific application.
11
+ ### END INIT INFO
12
+ set -e
13
+
14
+ AS_USER=<%= fetch(:faye_user) %>
15
+ APP_ROOT=<%= current_path %>
16
+ FAYE_CONF=<%= fetch(:faye_config) %>
17
+ PID=<%= fetch(:faye_pid) %>
18
+ PORT=<%= fetch(:faye_port) %>
19
+ CMD="cd <%= current_path %>; bundle exec rackup $FAYE_CONF -E production -D --pid $PID -p $PORT"
20
+
21
+ set -u
22
+
23
+ OLD_PIN="$PID.oldbin"
24
+
25
+ sig () {
26
+ test -s "$PID" && kill -$1 `cat $PID`
27
+ }
28
+
29
+ oldsig () {
30
+ test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
31
+ }
32
+
33
+ run () {
34
+ if [ "$(id -un)" = "$AS_USER" ]; then
35
+ eval $1
36
+ else
37
+ su -c "$1" - $AS_USER
38
+ fi
39
+ }
40
+
41
+ case "$1" in
42
+ start)
43
+ sig 0 && echo >&2 "Already running" && exit 0
44
+ run "$CMD"
45
+ ;;
46
+ stop)
47
+ sig QUIT && exit 0
48
+ echo >&2 "Not running"
49
+ ;;
50
+ force-stop)
51
+ sig TERM && exit 0
52
+ echo >&2 "Not running"
53
+ ;;
54
+ restart|reload)
55
+ sig HUP && echo reloaded OK && exit 0
56
+ echo >&2 "Couldn't reload, starting '$CMD' instead"
57
+ run "$CMD"
58
+ ;;
59
+ *)
60
+ echo >&2 "Usage: $0 <start|stop|restart|force-stop>"
61
+ exit 1
62
+ ;;
63
+ esac
@@ -88,6 +88,22 @@ server {
88
88
  add_header X-Frame-Options <%= fetch(:nginx_x_frame_options) %>;
89
89
  <% end %>
90
90
 
91
+
92
+ <% if fetch(:use_faye) %>
93
+ # Add acception of websockets for faye
94
+ location <%= fetch(:faye_mount_location) %> {
95
+ proxy_set_header Upgrade $http_upgrade;
96
+ proxy_set_header Connection "upgrade";
97
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
98
+ proxy_set_header X-Real-IP $remote_addr;
99
+ proxy_set_header Host $host;
100
+ proxy_http_version 1.1;
101
+ proxy_buffering off;
102
+ proxy_redirect off;
103
+ proxy_pass http://localhost:<%= fetch(:faye_port) %>;
104
+ }
105
+ <% end %>
106
+
91
107
  <% # FILE HANDLING %>
92
108
  <% if fetch(:use_unicorn) %>
93
109
  try_files $uri/index.html $uri @unicorn_<%= fetch(:app_config_name) %>;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-generals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stef Schenkelaars
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-30 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -66,6 +66,7 @@ files:
66
66
  - Rakefile
67
67
  - capistrano-generals.gemspec
68
68
  - lib/capistrano-generals.rb
69
+ - lib/capistrano/dsl/faye_paths.rb
69
70
  - lib/capistrano/dsl/nginx_paths.rb
70
71
  - lib/capistrano/dsl/puma_paths.rb
71
72
  - lib/capistrano/dsl/sidekiq_paths.rb
@@ -76,6 +77,7 @@ files:
76
77
  - lib/capistrano/generals/version.rb
77
78
  - lib/capistrano/tasks/defaults.rake
78
79
  - lib/capistrano/tasks/deploy/symlink.rake
80
+ - lib/capistrano/tasks/faye.rake
79
81
  - lib/capistrano/tasks/git.rake
80
82
  - lib/capistrano/tasks/nginx.rake
81
83
  - lib/capistrano/tasks/puma.rake
@@ -86,6 +88,8 @@ files:
86
88
  - lib/generators/capistrano/generals/puma_generator.rb
87
89
  - lib/generators/capistrano/generals/sidekiq_generator.rb
88
90
  - lib/generators/capistrano/generals/templates/_head.erb
91
+ - lib/generators/capistrano/generals/templates/faye.ru.erb
92
+ - lib/generators/capistrano/generals/templates/faye_init.sh.erb
89
93
  - lib/generators/capistrano/generals/templates/nginx.conf.erb
90
94
  - lib/generators/capistrano/generals/templates/puma.rb.erb
91
95
  - lib/generators/capistrano/generals/templates/puma_init.sh.erb