pixelforce_recipes 1.3 → 1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dd385481ab023261fb23d322e538df46a8ce209
4
- data.tar.gz: d19e58b2983804ce31d6f12630adaf34db0a1230
3
+ metadata.gz: 4b5e21e690c3f0a6ef398cf285f22ff5e9c652d3
4
+ data.tar.gz: c415d1d498cdbe3684460c73dd4298efe4785334
5
5
  SHA512:
6
- metadata.gz: f577ee0e574faec11bbb6aad1c873f1003ad74d2e2eef5eeadfab9614c15906d2f79ecc81468cbf1f51c840b9a8f2ae561d1a747f2f3e72232e40dd145a76f92
7
- data.tar.gz: 0883dd4c4dc3263aeb6020da0035ae9d91519729c6371865c0b43eb4a53f85aa90fe8b7a2753761a7acca52ba6eefb31f97bdc19b59de981ab7982ac81de3dc1
6
+ metadata.gz: 68d3980743a9b71969e2ce5339eb8417e26bc3b9c30ab4ccda765c74cd1c5acfe9708032cbbf287215ad016c6abe4e719792592e30527ce92629e3aaba37736c
7
+ data.tar.gz: e27fa4ca1a0ebc01467b18417351961f2e4dcd70c471e8321f4f23eb4571aa0a7dbe978b496e50c5e75f66cc408818cbc14b8a66eea455ad741e2dd83ce5896a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pixelforce_recipes (1.3)
4
+ pixelforce_recipes (1.4)
5
5
  capistrano (> 2.0.0)
6
6
 
7
7
  GEM
@@ -14,9 +14,9 @@ GEM
14
14
  i18n
15
15
  rake (>= 10.0.0)
16
16
  sshkit (>= 1.9.0)
17
- concurrent-ruby (1.0.5)
17
+ concurrent-ruby (1.1.3)
18
18
  diff-lcs (1.2.5)
19
- i18n (1.0.1)
19
+ i18n (1.1.1)
20
20
  concurrent-ruby (~> 1.0)
21
21
  net-scp (1.2.1)
22
22
  net-ssh (>= 2.6.5)
@@ -1,8 +1,16 @@
1
1
  require "pixelforce_recipes/version"
2
2
  require "capistrano"
3
3
 
4
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/base")
5
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/unicorn")
6
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/sidekiq")
7
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/puma")
8
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/logrotate")
4
+ if defined?(Capistrano::VERSION) && Capistrano::VERSION.to_s.split('.').first.to_i >= 3
5
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/base")
6
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/sidekiq")
7
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/resque")
8
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/logrotate")
9
+ else
10
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/base")
11
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/unicorn")
12
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/sidekiq")
13
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/resque")
14
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/puma")
15
+ require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/logrotate")
16
+ end
@@ -0,0 +1,4 @@
1
+ def template(from, to)
2
+ erb = File.read(File.expand_path("../../templates/#{from}", __FILE__))
3
+ upload! StringIO.new(ERB.new(erb).result(binding)), to
4
+ end
@@ -0,0 +1,9 @@
1
+ namespace :logrotate do
2
+ desc "Setup logrotate configuration for this application"
3
+ task :setup do
4
+ on roles(:app) do
5
+ template "logrotate.erb", "/tmp/logrotate"
6
+ sudo "mv /tmp/logrotate /etc/logrotate.d/#{fetch(:application)}"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ namespace :puma do
2
+
3
+ desc "Setup puma configuration for this application"
4
+ task :setup do
5
+ on roles(:web) do
6
+ template "puma_init.erb", "/tmp/puma"
7
+ sudo "mv /tmp/puma /etc/init.d/#{fetch(:application)}"
8
+ sudo "chmod +x /etc/init.d/#{fetch(:application)}"
9
+ sudo "update-rc.d #{fetch(:application)} defaults"
10
+ template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
11
+ sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
12
+ end
13
+ end
14
+
15
+ %w[start stop restart].each do |command|
16
+ desc "#{command} puma"
17
+ task command do
18
+ on roles(:web) do
19
+ execute "/etc/init.d/#{fetch(:application)} #{command}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ namespace :resque do
2
+ desc "Install resque"
3
+
4
+ desc "Setup resque configuration for this application"
5
+ task :setup do
6
+ on roles(:resque) do
7
+ template "resque_init.erb", "/tmp/resque"
8
+ sudo "mv /tmp/resque /etc/init.d/resque"
9
+ sudo "chmod +x /etc/init.d/resque"
10
+ sudo "update-rc.d resque defaults"
11
+ end
12
+ end
13
+
14
+ %w[start stop restart].each do |command|
15
+ desc "#{command} resque"
16
+ task command do
17
+ on roles(:resque) do
18
+ execute "/etc/init.d/resque #{command}"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ namespace :sidekiq do
2
+ desc "Install sidekiq"
3
+
4
+ desc "Setup sidekiq configuration for this application"
5
+ task :setup do
6
+ on roles(:sidekiq) do
7
+ template "sidekiq_init.erb", "/tmp/sidekiq"
8
+ sudo "mv /tmp/sidekiq /etc/init.d/sidekiq"
9
+ sudo "chmod +x /etc/init.d/sidekiq"
10
+ sudo "update-rc.d sidekiq defaults"
11
+ end
12
+ end
13
+
14
+ %w[start stop restart].each do |command|
15
+ desc "#{command} sidekiq"
16
+ task command do
17
+ on roles(:resque) do
18
+ execute "/etc/init.d/sidekiq #{command}"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ namespace :unicorn do
2
+ desc "Install unicorn"
3
+
4
+ desc "Setup unicorn configuration for this application"
5
+ task :setup do
6
+ on roles(:web) do
7
+ template "unicorn_init.erb", "/tmp/unicorn"
8
+ sudo "mv /tmp/unicorn /etc/init.d/#{fetch(:application)}"
9
+ sudo "chmod +x /etc/init.d/#{fetch(:application)}"
10
+ sudo "update-rc.d #{fetch(:application)} defaults"
11
+ template "nginx_config.erb", "/tmp/nginx_config"
12
+ sudo "mv /tmp/nginx_config /etc/nginx/sites-enabled/#{fetch(:application)}"
13
+ end
14
+ end
15
+
16
+ %w[start stop restart].each do |command|
17
+ desc "#{command} unicorn"
18
+ task command do
19
+ on roles(:web) do
20
+ execute "/etc/init.d/#{fetch(:application)} #{command}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ if Capistrano::Configuration.instance(false)
2
+ Capistrano::Configuration.instance(true).load do |instance|
3
+ namespace :resque do
4
+ desc "Install resque"
5
+
6
+ desc "Setup resque configuration for this application"
7
+ task :setup, roles: :resque do
8
+ template "resque_init.erb", "/tmp/resque"
9
+ run "#{sudo} mv /tmp/resque /etc/init.d/resque"
10
+ run "#{sudo} chmod +x /etc/init.d/resque"
11
+ run "#{sudo} update-rc.d resque defaults"
12
+ end
13
+
14
+ %w[start stop restart].each do |command|
15
+ desc "#{command} resque"
16
+ task command do
17
+ run "/etc/init.d/resque #{command}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,4 +1,4 @@
1
- <%= deploy_to %>/shared/log/*.log {
1
+ <%= fetch(:deploy_to) %>/shared/log/*.log {
2
2
  daily
3
3
  missingok
4
4
  copytruncate
@@ -1,26 +1,26 @@
1
- upstream <%= application %> {
2
- server unix:/tmp/<%= application %>.sock fail_timeout=0;
1
+ upstream <%= fetch(:application) %> {
2
+ server unix:/tmp/<%= fetch(:application) %>.sock fail_timeout=0;
3
3
  }
4
4
 
5
5
  server {
6
6
  listen 80;
7
- server_name <%= server_address %>;
8
- root <%= deploy_to %>/current/public;
7
+ server_name <%= fetch(:server_address) %>;
8
+ root <%= fetch(:deploy_to) %>/current/public;
9
9
 
10
- try_files $uri/index.html $uri @<%= application %>;
10
+ try_files $uri/index.html $uri @<%= fetch(:application) %>;
11
11
 
12
12
  location ~* ^(/assets|/favicon.ico) {
13
13
  access_log off;
14
14
  expires max;
15
15
  }
16
16
 
17
- location @<%= application %> {
17
+ location @<%= fetch(:application) %> {
18
18
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19
19
  proxy_set_header Host $http_host;
20
20
  proxy_redirect off;
21
21
  proxy_buffering on;
22
22
  proxy_set_header X-Real-IP $remote_addr;
23
- proxy_pass http://<%= application %>;
23
+ proxy_pass http://<%= fetch(:application) %>;
24
24
  }
25
25
 
26
26
  error_page 500 502 503 504 /500.html;
@@ -1,14 +1,14 @@
1
- upstream <%= application %> {
2
- server unix:/tmp/<%= application %>.sock fail_timeout=0;
1
+ upstream <%= fetch(:application) %> {
2
+ server unix:/tmp/<%= fetch(:application) %>.sock fail_timeout=0;
3
3
  }
4
4
 
5
5
  server {
6
6
  listen 80 default_server deferred;
7
- server_name <%= server_address %>;
7
+ server_name <%= fetch(:server_address) %>;
8
8
 
9
- root <%= deploy_to %>/current/public;
10
- access_log <%= deploy_to %>/current/log/nginx.access.log;
11
- error_log <%= deploy_to %>/current/log/nginx.error.log info;
9
+ root <%= fetch(:deploy_to) %>/current/public;
10
+ access_log <%= fetch(:deploy_to) %>/current/log/nginx.access.log;
11
+ error_log <%= fetch(:deploy_to) %>/current/log/nginx.error.log info;
12
12
 
13
13
  location ^~ /assets/ {
14
14
  gzip_static on;
@@ -16,19 +16,19 @@ server {
16
16
  add_header Cache-Control public;
17
17
  }
18
18
 
19
- try_files $uri $uri @<%= application %>;
20
- location @<%= application %> {
19
+ try_files $uri $uri @<%= fetch(:application) %>;
20
+ location @<%= fetch(:application) %> {
21
21
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
22
22
  proxy_set_header Host $http_host;
23
23
  proxy_redirect off;
24
24
  proxy_buffering on;
25
25
  proxy_set_header X-Real-IP $remote_addr;
26
26
 
27
- proxy_pass http://<%= application %>;
27
+ proxy_pass http://<%= fetch(:application) %>;
28
28
  }
29
29
 
30
30
  location /cable {
31
- proxy_pass http://<%= application %>;
31
+ proxy_pass http://<%= fetch(:application) %>;
32
32
  proxy_http_version 1.1;
33
33
  proxy_set_header Upgrade $http_upgrade;
34
34
  proxy_set_header Connection "upgrade";
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  ### BEGIN INIT INFO
4
- # Provides: <%= application %>
4
+ # Provides: <%= fetch(:application) %>
5
5
  # Required-Start: $local_fs $remote_fs $network $syslog
6
6
  # Required-Stop: $local_fs $remote_fs $network $syslog
7
7
  # Default-Start: 2 3 4 5
@@ -10,10 +10,10 @@
10
10
  # Description: starts puma
11
11
  ### END INIT INFO
12
12
 
13
- USER="<%= user %>"
13
+ USER="<%= fetch(:user) %>"
14
14
  DAEMON=puma
15
- PROJECT_PATH="<%= deploy_to %>"
16
- DAEMON_OPTS="-e <%= rails_env %>"
15
+ PROJECT_PATH="<%= fetch(:deploy_to) %>"
16
+ DAEMON_OPTS="-e <%= fetch(:rails_env) %>"
17
17
  NAME=puma
18
18
  DESC="puma app for $USER"
19
19
  PID="$PROJECT_PATH/shared/pids/puma.pid"
@@ -0,0 +1,49 @@
1
+ #!/bin/bash
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: resque
5
+ # Required-Start: $local_fs $remote_fs $network $syslog
6
+ # Required-Stop: $local_fs $remote_fs $network $syslog
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: resque worker via init.d
10
+ # Description: starts resque
11
+ ### END INIT INFO
12
+
13
+ USER="deploy"
14
+ PROJECT_PATH="<%= fetch(:deploy_to) %>"
15
+ NAME=resque
16
+ DESC="Resque app for $USER"
17
+ PID="$PROJECT_PATH/shared/pids/resque.pid"
18
+ LOGFILE="$PROJECT_PATH/shared/log/resque.log"
19
+ CD_TO_APP_DIR="cd $PROJECT_PATH/current"
20
+
21
+
22
+ case "$1" in
23
+ start)
24
+ START_DAEMON_PROCESS="bundle exec rake RAILS_ENV=<%= fetch(:rails_env) %> QUEUE='*' PIDFILE=$PID BACKGROUND=yes environment resque:work 2>&1 > $LOGFILE"
25
+ echo -n "Starting $DESC: "
26
+ if [ `whoami` = 'root' ]; then
27
+ su - $USER -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
28
+ else
29
+ /bin/bash -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
30
+ fi
31
+ echo "$NAME."
32
+ ;;
33
+ stop)
34
+ STOP_DAEMON_PROCESS="test -f $PID && kill -s QUIT `cat $PID` && rm -f $PID"
35
+ echo -n "Stopping $DESC: "
36
+ if [ `whoami` = 'root' ]; then
37
+ su - $USER -c "$CD_TO_APP_DIR && $STOP_DAEMON_PROCESS"
38
+ else
39
+ /bin/bash -l -c "$CD_TO_APP_DIR && $STOP_DAEMON_PROCESS"
40
+ fi
41
+ echo "$NAME."
42
+ ;;
43
+ *)
44
+ echo "Usage: $NAME {start|stop|restart|reload}" >&2
45
+ exit 1
46
+ ;;
47
+ esac
48
+
49
+ exit 0
@@ -12,7 +12,7 @@
12
12
 
13
13
  USER="deploy"
14
14
  DAEMON=sidekiq
15
- PROJECT_PATH="<%= deploy_to %>"
15
+ PROJECT_PATH="<%= fetch(:deploy_to) %>"
16
16
  NAME=sidekiq
17
17
  DESC="Sidekiq app for $USER"
18
18
  PID="$PROJECT_PATH/shared/pids/sidekiq.pid"
@@ -21,13 +21,13 @@ CD_TO_APP_DIR="cd $PROJECT_PATH/current"
21
21
 
22
22
  case "$1" in
23
23
  start)
24
- START_DAEMON_PROCESS="bundle exec sidekiq -d -e <%= rails_env %> -L $LOGFILE -P $PID"
24
+ START_DAEMON_PROCESS="bundle exec sidekiq -d -e <%= fetch(:rails_env) %> -L $LOGFILE -P $PID"
25
25
 
26
26
  echo -n "Starting $DESC: "
27
27
  if [ `whoami` = 'root' ]; then
28
28
  su - $USER -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
29
29
  else
30
- $CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS
30
+ /bin/bash -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
31
31
  fi
32
32
  echo "$NAME."
33
33
  ;;
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  ### BEGIN INIT INFO
4
- # Provides: <%= application %>
4
+ # Provides: <%= fetch(:application) %>
5
5
  # Required-Start: $local_fs $remote_fs $network $syslog
6
6
  # Required-Stop: $local_fs $remote_fs $network $syslog
7
7
  # Default-Start: 2 3 4 5
@@ -10,10 +10,10 @@
10
10
  # Description: starts unicorn
11
11
  ### END INIT INFO
12
12
 
13
- USER="<%= user %>"
13
+ USER="<%= fetch(:user) %>"
14
14
  DAEMON=unicorn
15
- PROJECT_PATH="<%= deploy_to %>"
16
- DAEMON_OPTS="-c $PROJECT_PATH/current/config/unicorn.rb -E <%= rails_env %> -D"
15
+ PROJECT_PATH="<%= fetch(:deploy_to) %>"
16
+ DAEMON_OPTS="-c $PROJECT_PATH/current/config/unicorn.rb -E <%= fetch(:rails_env) %> -D"
17
17
  NAME=unicorn
18
18
  DESC="Unicorn app for $USER"
19
19
  PID="$PROJECT_PATH/shared/pids/unicorn.pid"
@@ -1,3 +1,3 @@
1
1
  module PixelforceRecipes
2
- VERSION = "1.3"
2
+ VERSION = "1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixelforce_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Zhang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-29 00:00:00.000000000 Z
11
+ date: 2018-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,17 +83,25 @@ files:
83
83
  - bin/console
84
84
  - bin/setup
85
85
  - lib/pixelforce_recipes.rb
86
- - lib/pixelforce_recipes/base.rb
87
- - lib/pixelforce_recipes/logrotate.rb
88
- - lib/pixelforce_recipes/puma.rb
89
- - lib/pixelforce_recipes/sidekiq.rb
86
+ - lib/pixelforce_recipes/capistrano_3_recipes/base.rb
87
+ - lib/pixelforce_recipes/capistrano_3_recipes/logrotate.rb
88
+ - lib/pixelforce_recipes/capistrano_3_recipes/puma.rb
89
+ - lib/pixelforce_recipes/capistrano_3_recipes/resque.rb
90
+ - lib/pixelforce_recipes/capistrano_3_recipes/sidekiq.rb
91
+ - lib/pixelforce_recipes/capistrano_3_recipes/unicorn.rb
92
+ - lib/pixelforce_recipes/legacy_recipes/base.rb
93
+ - lib/pixelforce_recipes/legacy_recipes/logrotate.rb
94
+ - lib/pixelforce_recipes/legacy_recipes/puma.rb
95
+ - lib/pixelforce_recipes/legacy_recipes/resque.rb
96
+ - lib/pixelforce_recipes/legacy_recipes/sidekiq.rb
97
+ - lib/pixelforce_recipes/legacy_recipes/unicorn.rb
90
98
  - lib/pixelforce_recipes/templates/logrotate.erb
91
99
  - lib/pixelforce_recipes/templates/nginx_config.erb
92
100
  - lib/pixelforce_recipes/templates/nginx_puma_config.erb
93
101
  - lib/pixelforce_recipes/templates/puma_init.erb
102
+ - lib/pixelforce_recipes/templates/resque_init.erb
94
103
  - lib/pixelforce_recipes/templates/sidekiq_init.erb
95
104
  - lib/pixelforce_recipes/templates/unicorn_init.erb
96
- - lib/pixelforce_recipes/unicorn.rb
97
105
  - lib/pixelforce_recipes/version.rb
98
106
  - pixelforce_recipes.gemspec
99
107
  homepage: https://git.pixelforcesystems.com.au/