teleporter 0.0.15 → 0.0.16

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: 5bc1577f3f9290f6a4275836e730defc5fc78a88
4
- data.tar.gz: 73e66a6b98e16a75d6bbefd0c1442c9814f88da5
3
+ metadata.gz: 3dfe68013173039db4725ce3acac288a192e6f4e
4
+ data.tar.gz: 9e9a9957356c1403abf9700b0fb57482db2b6f9b
5
5
  SHA512:
6
- metadata.gz: 8800bf16f79c5e513c5ca04fe89a4860f8da7dd045da91d2967ec78e65e70b57e8315a72565ca0b0105987364b0b3f18abe3ef830b9bb3bc7a0e2191d37c5d16
7
- data.tar.gz: 87fbd5b697d7b637ad03a5c798e5f6317ef3cd2c9247640c50b321ad6cd65731013cb66c14fe4f1d90958333d7ba31996d55d9cd3c2760adb6214e21df6cbd82
6
+ metadata.gz: b9aefe47ec8ef2b5a66a115c3c33a7979e6165ba131ec65a15c5be6c9b14ee89dd08d504258e1b256b1aa947575bbaaa0c68da4143bf0225441d602daa75d20b
7
+ data.tar.gz: 8cde798b53c862ac12c1b2deba8ed0d593a07da6071eb20776478a99ce8e059272219af5b81b6f67b45fba40eadfb747b45b4395a53398597ad294a8e453b820
@@ -9,6 +9,7 @@ module Initial
9
9
  gem 'capistrano-bundler'
10
10
  gem 'capistrano-rails'
11
11
  gem 'capistrano-sidekiq' , github: 'seuros/capistrano-sidekiq'
12
+ gem 'capistrano3-puma'
12
13
  end
13
14
 
14
15
  Bundler.with_clean_env do
@@ -18,9 +19,6 @@ module Initial
18
19
  directory 'capistrano/tasks', 'lib/capistrano/tasks'
19
20
  directory 'capistrano/shared', 'config/deploy/shared'
20
21
 
21
- template "capistrano/lib/substitute_strings.rb", "lib/capistrano/substitute_strings.rb"
22
- template "capistrano/lib/template.rb", "lib/capistrano/template.rb"
23
-
24
22
  run 'cap install'
25
23
 
26
24
  uncomment_lines 'Capfile', /require 'capistrano\/rbenv'/
@@ -29,127 +27,14 @@ module Initial
29
27
  uncomment_lines 'Capfile', /require 'capistrano\/rails\/migrations'/
30
28
  insert_into_file "Capfile", "require 'capistrano/sidekiq'\n",
31
29
  after: "require 'capistrano/rails/migrations'\n"
30
+ insert_into_file "Capfile", "require 'capistrano/sidekiq'\n",
31
+ after: "require 'capistrano/puma'\n"
32
+ insert_into_file "Capfile", "require 'capistrano/sidekiq'\n",
33
+ after: "require 'capistrano/puma/monit'\n"
32
34
 
35
+ copy_file 'capistrano/deploy/deploy.rb', 'config/deploy.rb'
36
+ copy_file 'capistrano/deploy/production.rb', 'config/deploy/production.rb'
33
37
 
34
- append_to_file 'config/deploy.rb' do
35
- <<-EOT
36
- set :rbenv_type, :system
37
- set :rbenv_ruby, '2.1.2'
38
- set :rbenv_prefix, "RBENV_ROOT=\#{fetch(:rbenv_path)} RBENV_VERSION=\#{fetch(:rbenv_ruby)} \#{fetch(:rbenv_path)}/bin/rbenv exec"
39
- set :rbenv_map_bins, %w{rake gem bundle ruby rails}
40
- set :linked_files, %w{config/database.yml config/application.yml}
41
- set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
42
- set(:config_files, %w(
43
- nginx.conf
44
- application.yml
45
- database.example.yml
46
- log_rotation
47
- monit
48
- monit_sidekiq
49
- unicorn.rb
50
- unicorn_init.sh
51
- sidekiq_init.sh
52
- ))
53
- set(:executable_config_files, %w(
54
- unicorn_init.sh
55
- sidekiq_init.sh
56
- ))
57
- set(:symlinks, [
58
- {
59
- source: "nginx.conf",
60
- link: "/etc/nginx/sites-enabled/{{full_app_name}}"
61
- },
62
- {
63
- source: "unicorn_init.sh",
64
- link: "/etc/init.d/unicorn_{{full_app_name}}"
65
- },
66
- {
67
- source: "log_rotation",
68
- link: "/etc/logrotate.d/{{full_app_name}}"
69
- },
70
- {
71
- source: "monit",
72
- link: "/etc/monit/conf.d/{{full_app_name}}.conf"
73
- },
74
- {
75
- source: "monit_sidekiq",
76
- link: "/etc/monit/conf.d/sidekiq_{{full_app_name}}.conf"
77
- },
78
- {
79
- source: "sidekiq_init.sh",
80
- link: "/etc/init.d/sidekiq_{{full_app_name}}"
81
- }
82
- ])
83
- namespace :deploy do
84
- desc 'Normalize asset timestamps'
85
- task migr: fetch(:stage) do
86
- on roles(:app) do
87
- within release_path do
88
- execute :rake, "migrate:users", "RAILS_ENV=\#{fetch(:stage)}"
89
- end
90
- end
91
- end
92
- end
93
-
94
- namespace :deploy do
95
- task clear_cache: fetch(:stage) do
96
- on roles(:app) do
97
- within release_path do
98
- execute :rake, 'tmp:cache:clear'
99
- end
100
- end
101
- end
102
- end
103
-
104
- namespace :deploy do
105
- # make sure we're deploying what we think we're deploying
106
- before :deploy, "deploy:check_revision"
107
- # only allow a deploy with passing tests to deployed
108
- # compile assets locally then rsync
109
- #after 'deploy:symlink:shared', 'deploy:compile_assets_locally'
110
- after :finishing, 'deploy:cleanup'
111
- after :finishing, 'deploy:restart'
112
- after :finishing, 'deploy:clear_cache'
113
- #after :finishing, 'sidekiq:restart'
114
- #after :finishing, 'deploy:migr'
115
- end
116
-
117
- EOT
118
- end
119
-
120
- append_to_file 'config/deploy/production.rb' do
121
- <<-EOT
122
- set :stage, :production
123
- set :branch, "master"
124
-
125
- # used in case we're deploying multiple versions of the same
126
- # app side by side. Also provides quick sanity checks when looking
127
- # at filepaths
128
- set :full_app_name, "\#{fetch(:application)}_\#{fetch(:stage)}"
129
-
130
- server '95.85.33.125', user: 'deploy', roles: %w{web app db}, primary: true
131
-
132
- set :deploy_to, "/home/\#{fetch(:deploy_user)}/apps/\#{fetch(:full_app_name)}"
133
-
134
- # dont try and infer something as important as environment from
135
- # stage name.
136
- set :rails_env, :production
137
-
138
- # number of unicorn workers, this will be reflected in
139
- # the unicorn.rb and the monit configs
140
- set :unicorn_worker_count, 2
141
-
142
- # whether we're using ssl or not, used for building nginx
143
- # config file
144
- set :enable_ssl, false
145
- EOT
146
- end
147
-
148
- p '*****'
149
- p 'config application name in config/deploy.rb'
150
- p 'config git repo path in config/deploy.rb'
151
- p 'remove default deploy:start task in config/deploy.rb'
152
- p 'remove default examples in config/production/deploy.rb'
153
38
  end
154
39
  end
155
40
  end
@@ -0,0 +1,100 @@
1
+ lock '3.2.1'
2
+
3
+ set :application, 'my_app_name'
4
+ set :repo_url, 'git@github.com:itsNikolay/puma-testing.git'
5
+ set :deploy_user, 'deploy'
6
+
7
+ set :puma_init_active_record, true
8
+
9
+ set :rbenv_type, :system
10
+ set :rbenv_ruby, '2.1.2'
11
+ set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
12
+ set :rbenv_map_bins, %w{rake gem bundle ruby rails}
13
+ set :linked_files, %w{config/database.yml config/application.yml config/secrets.yml}
14
+ set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
15
+ set(:config_files, %w(
16
+ nginx.conf
17
+ application.yml
18
+ database.example.yml
19
+ log_rotation
20
+ monit
21
+ monit_sidekiq
22
+ puma.conf
23
+ puma
24
+ run-puma
25
+ sidekiq_init.sh
26
+ secrets.yml
27
+ ))
28
+ set(:executable_config_files, %w(
29
+ puma
30
+ run-puma
31
+ sidekiq_init.sh
32
+ ))
33
+ set(:symlinks, [
34
+ {
35
+ source: "nginx.conf",
36
+ link: "/etc/nginx/sites-enabled/{{full_app_name}}"
37
+ },
38
+ {
39
+ source: "puma",
40
+ link: "/etc/init.d/puma"
41
+ },
42
+ {
43
+ source: "run-puma",
44
+ link: "/usr/local/bin/run-puma"
45
+ },
46
+ {
47
+ source: "puma.conf",
48
+ link: "/etc/puma.conf"
49
+ },
50
+ {
51
+ source: "log_rotation",
52
+ link: "/etc/logrotate.d/{{full_app_name}}"
53
+ },
54
+ {
55
+ source: "monit",
56
+ link: "/etc/monit/conf.d/{{full_app_name}}.conf"
57
+ },
58
+ {
59
+ source: "monit_sidekiq",
60
+ link: "/etc/monit/conf.d/sidekiq_{{full_app_name}}.conf"
61
+ },
62
+ {
63
+ source: "sidekiq_init.sh",
64
+ link: "/etc/init.d/sidekiq_{{full_app_name}}"
65
+ },
66
+ ])
67
+ namespace :deploy do
68
+ desc 'Normalize asset timestamps'
69
+ task migr: fetch(:stage) do
70
+ on roles(:app) do
71
+ within release_path do
72
+ execute :rake, "migrate:users", "RAILS_ENV=#{fetch(:stage)}"
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ namespace :deploy do
79
+ task clear_cache: fetch(:stage) do
80
+ on roles(:app) do
81
+ within release_path do
82
+ execute :rake, 'tmp:cache:clear'
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ namespace :deploy do
89
+ # make sure we're deploying what we think we're deploying
90
+ before :deploy, "deploy:check_revision"
91
+ # only allow a deploy with passing tests to deployed
92
+ # compile assets locally then rsync
93
+ #after 'deploy:symlink:shared', 'deploy:compile_assets_locally'
94
+ after :finishing, 'deploy:cleanup'
95
+ after :finishing, 'deploy:restart'
96
+ after :finishing, 'deploy:clear_cache'
97
+ #after :finishing, 'sidekiq:restart'
98
+ #after :finishing, 'deploy:migr'
99
+ end
100
+
@@ -0,0 +1,19 @@
1
+ set :stage, :production
2
+ set :branch, "master"
3
+
4
+ # used in case we're deploying multiple versions of the same
5
+ # app side by side. Also provides quick sanity checks when looking
6
+ # at filepaths
7
+ set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
8
+
9
+ server '192.168.33.10', user: 'deploy', roles: %w{web app db}, primary: true
10
+
11
+ set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
12
+
13
+ # dont try and infer something as important as environment from
14
+ # stage name.
15
+ set :rails_env, :production
16
+
17
+ # whether we're using ssl or not, used for building nginx
18
+ # config file
19
+ set :enable_ssl, false
@@ -1,22 +1,7 @@
1
- <% application = fetch(:application) %>
2
- set mail-format { subject: <%= "#{fetch(:full_app_name)} - #{fetch(:rails_env)}" %> $SERVICE $EVENT at $DATE }
3
-
4
- check process unicorn
5
- with pidfile <%= current_path %>/tmp/pids/unicorn.pid
6
- start program = "/etc/init.d/unicorn_<%= application %>_<%= fetch(:rails_env)%> start"
7
- stop program = "/etc/init.d/unicorn_<%= application %>_<%= fetch(:rails_env)%> stop"
8
- if mem is greater than 300.0 MB for 1 cycles then restart # eating up memory?
9
- if cpu is greater than 50% for 2 cycles then alert # send an email to admin
10
- if cpu is greater than 80% for 30 cycles then restart # hung process?
11
- group unicorn
12
-
13
- <% (0..(fetch(:unicorn_worker_count) -1)).each do |worker| %>
14
- check process unicorn_worker_<%= (5000 + worker).to_s %>
15
- with pidfile <%= current_path %>/tmp/pids/unicorn.<%= (5000 + worker).to_s %>.pid
16
- start program = "/bin/true"
17
- stop program = "/etc/init.d/unicorn_<%= application %>_<%= fetch(:rails_env)%> kill_worker <%= (5000 + worker).to_s %>"
18
- if mem is greater than 350.0 MB for 1 cycles then restart
19
- if cpu is greater than 80% for 30 cycles then restart
20
-
21
- group unicorn_workers
22
- <% end %>
1
+ # Monit configuration for Puma
2
+ # Service name: <%= puma_monit_service_name %>
3
+ #
4
+ check process <%= puma_monit_service_name %>
5
+ with pidfile "<%= fetch(:puma_pid) %>"
6
+ start program = "/usr/bin/sudo -u <%= fetch(:deploy_user) %> /bin/bash -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:bundle] %> exec puma -C <%= fetch(:puma_conf) %> --daemon'"
7
+ stop program = "/usr/bin/sudo -u <%= fetch(:deploy_user) %> /bin/bash -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:bundle] %> exec pumactl -S <%= fetch(:puma_state) %> stop'"
@@ -1,5 +1,5 @@
1
- upstream unicorn {
2
- server unix:/tmp/unicorn.<%= fetch(:full_app_name) %>.sock fail_timeout=0;
1
+ upstream puma {
2
+ server unix:/<%= fetch(:deploy_to) %>/shared/tmp/sockets/puma.sock fail_timeout=0;
3
3
  }
4
4
 
5
5
  server {
@@ -12,12 +12,12 @@ server {
12
12
  add_header Cache-Control public;
13
13
  }
14
14
 
15
- try_files $uri/index.html $uri @unicorn;
16
- location @unicorn {
15
+ try_files $uri/index.html $uri @puma;
16
+ location @puma {
17
17
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
18
18
  proxy_set_header Host $http_host;
19
19
  proxy_redirect off;
20
- proxy_pass http://unicorn;
20
+ proxy_pass http://puma;
21
21
  }
22
22
 
23
23
  error_page 500 502 503 504 /500.html;
@@ -36,13 +36,13 @@ server {
36
36
  add_header Cache-Control public;
37
37
  }
38
38
 
39
- try_files $uri/index.html $uri @unicorn;
40
- location @unicorn {
39
+ try_files $uri/index.html $uri @puma;
40
+ location @puma {
41
41
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
42
42
  proxy_set_header X-Forwarded-Proto https;
43
43
  proxy_set_header Host $http_host;
44
44
  proxy_redirect off;
45
- proxy_pass http://unicorn;
45
+ proxy_pass http://puma;
46
46
  }
47
47
 
48
48
  error_page 500 502 503 504 /500.html;
@@ -0,0 +1 @@
1
+ <%= current_path %>,<%= fetch(:deploy_user) %>
@@ -0,0 +1,332 @@
1
+ #! /bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: puma
4
+ # Required-Start: $remote_fs $syslog
5
+ # Required-Stop: $remote_fs $syslog
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: Example initscript
9
+ # Description: This file should be used to construct scripts to be
10
+ # placed in /etc/init.d.
11
+ ### END INIT INFO
12
+
13
+ # Author: Darío Javier Cravero <dario@exordo.com>
14
+ #
15
+ # Do NOT "set -e"
16
+
17
+ # PATH should only include /usr/* if it runs after the mountnfs.sh script
18
+ PATH=/usr/local/bin:/usr/local/sbin/:/sbin:/usr/sbin:/bin:/usr/bin
19
+ DESC="Puma rack web server"
20
+ NAME=puma
21
+ DAEMON=$NAME
22
+ SCRIPTNAME=/etc/init.d/$NAME
23
+ CONFIG=/etc/puma.conf
24
+ JUNGLE=`cat $CONFIG`
25
+ RUNPUMA=/usr/local/bin/run-puma
26
+
27
+ # Load the VERBOSE setting and other rcS variables
28
+ . /lib/init/vars.sh
29
+
30
+ # Define LSB log_* functions.
31
+ # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
32
+ . /lib/lsb/init-functions
33
+
34
+ #
35
+ # Function that starts the jungle
36
+ #
37
+ do_start() {
38
+ log_daemon_msg "=> Running the jungle..."
39
+ for i in $JUNGLE; do
40
+ dir=`echo $i | cut -d , -f 1`
41
+ user=`echo $i | cut -d , -f 2`
42
+ config_file=`echo $i | cut -d , -f 3`
43
+ if [ "$config_file" = "" ]; then
44
+ config_file="$dir/config/puma.rb"
45
+ fi
46
+ log_file=`echo $i | cut -d , -f 4`
47
+ if [ "$log_file" = "" ]; then
48
+ log_file="$dir/log/puma.log"
49
+ fi
50
+ do_start_one $dir $user $config_file $log_file
51
+ done
52
+ }
53
+
54
+ do_start_one() {
55
+ PIDFILE=$1/tmp/puma/pid
56
+ if [ -e $PIDFILE ]; then
57
+ PID=`cat $PIDFILE`
58
+ # If the puma isn't running, run it, otherwise restart it.
59
+ if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
60
+ do_start_one_do $1 $2 $3 $4
61
+ else
62
+ do_restart_one $1
63
+ fi
64
+ else
65
+ do_start_one_do $1 $2 $3 $4
66
+ fi
67
+ }
68
+
69
+ do_start_one_do() {
70
+ log_daemon_msg "--> Woke up puma $1"
71
+ log_daemon_msg "user $2"
72
+ log_daemon_msg "log to $4"
73
+ start-stop-daemon --verbose --start --chdir $1 --chuid $2 --background --exec $RUNPUMA -- $1 $3 $4
74
+ }
75
+
76
+ #
77
+ # Function that stops the jungle
78
+ #
79
+ do_stop() {
80
+ log_daemon_msg "=> Putting all the beasts to bed..."
81
+ for i in $JUNGLE; do
82
+ dir=`echo $i | cut -d , -f 1`
83
+ do_stop_one $dir
84
+ done
85
+ }
86
+ #
87
+ # Function that stops the daemon/service
88
+ #
89
+ do_stop_one() {
90
+ log_daemon_msg "--> Stopping $1"
91
+ PIDFILE=$1/tmp/puma/pid
92
+ STATEFILE=$1/tmp/puma/state
93
+ if [ -e $PIDFILE ]; then
94
+ PID=`cat $PIDFILE`
95
+ if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
96
+ log_daemon_msg "---> Puma $1 isn't running."
97
+ else
98
+ log_daemon_msg "---> About to kill PID `cat $PIDFILE`"
99
+ pumactl --state $STATEFILE stop
100
+ # Many daemons don't delete their pidfiles when they exit.
101
+ rm -f $PIDFILE $STATEFILE
102
+ fi
103
+ else
104
+ log_daemon_msg "---> No puma here..."
105
+ fi
106
+ return 0
107
+ }
108
+
109
+ #
110
+ # Function that restarts the jungle
111
+ #
112
+ do_restart() {
113
+ for i in $JUNGLE; do
114
+ dir=`echo $i | cut -d , -f 1`
115
+ do_restart_one $dir
116
+ done
117
+ }
118
+
119
+ #
120
+ # Function that sends a SIGUSR2 to the daemon/service
121
+ #
122
+ do_restart_one() {
123
+ PIDFILE=$1/tmp/puma/pid
124
+ i=`grep $1 $CONFIG`
125
+ dir=`echo $i | cut -d , -f 1`
126
+
127
+ if [ -e $PIDFILE ]; then
128
+ log_daemon_msg "--> About to restart puma $1"
129
+ pumactl --state $dir/tmp/puma/state restart
130
+ # kill -s USR2 `cat $PIDFILE`
131
+ # TODO Check if process exist
132
+ else
133
+ log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
134
+ user=`echo $i | cut -d , -f 2`
135
+ config_file=`echo $i | cut -d , -f 3`
136
+ if [ "$config_file" = "" ]; then
137
+ config_file="$dir/config/puma.rb"
138
+ fi
139
+ log_file=`echo $i | cut -d , -f 4`
140
+ if [ "$log_file" = "" ]; then
141
+ log_file="$dir/log/puma.log"
142
+ fi
143
+ do_start_one $dir $user $config_file $log_file
144
+ fi
145
+ return 0
146
+ }
147
+
148
+ #
149
+ # Function that statuss the jungle
150
+ #
151
+ do_status() {
152
+ for i in $JUNGLE; do
153
+ dir=`echo $i | cut -d , -f 1`
154
+ do_status_one $dir
155
+ done
156
+ }
157
+
158
+ #
159
+ # Function that sends a SIGUSR2 to the daemon/service
160
+ #
161
+ do_status_one() {
162
+ PIDFILE=$1/tmp/puma/pid
163
+ i=`grep $1 $CONFIG`
164
+ dir=`echo $i | cut -d , -f 1`
165
+
166
+ if [ -e $PIDFILE ]; then
167
+ log_daemon_msg "--> About to status puma $1"
168
+ pumactl --state $dir/tmp/puma/state stats
169
+ # kill -s USR2 `cat $PIDFILE`
170
+ # TODO Check if process exist
171
+ else
172
+ log_daemon_msg "--> $1 isn't there :(..."
173
+ fi
174
+ return 0
175
+ }
176
+
177
+ do_add() {
178
+ str=""
179
+ # App's directory
180
+ if [ -d "$1" ]; then
181
+ if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then
182
+ str=$1
183
+ else
184
+ echo "The app is already being managed. Remove it if you want to update its config."
185
+ exit 1
186
+ fi
187
+ else
188
+ echo "The directory $1 doesn't exist."
189
+ exit 1
190
+ fi
191
+ # User to run it as
192
+ if [ "`grep -c "^$2:" /etc/passwd`" -eq 0 ]; then
193
+ echo "The user $2 doesn't exist."
194
+ exit 1
195
+ else
196
+ str="$str,$2"
197
+ fi
198
+ # Config file
199
+ if [ "$3" != "" ]; then
200
+ if [ -e $3 ]; then
201
+ str="$str,$3"
202
+ else
203
+ echo "The config file $3 doesn't exist."
204
+ exit 1
205
+ fi
206
+ fi
207
+ # Log file
208
+ if [ "$4" != "" ]; then
209
+ str="$str,$4"
210
+ fi
211
+
212
+ # Add it to the jungle
213
+ echo $str >> $CONFIG
214
+ log_daemon_msg "Added a Puma to the jungle: $str. You still have to start it though."
215
+ }
216
+
217
+ do_remove() {
218
+ if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then
219
+ echo "There's no app $1 to remove."
220
+ else
221
+ # Stop it first.
222
+ do_stop_one $1
223
+ # Remove it from the config.
224
+ sed -i "\\:^$1:d" $CONFIG
225
+ log_daemon_msg "Removed a Puma from the jungle: $1."
226
+ fi
227
+ }
228
+
229
+ case "$1" in
230
+ start)
231
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
232
+ if [ "$#" -eq 1 ]; then
233
+ do_start
234
+ else
235
+ i=`grep $2 $CONFIG`
236
+ dir=`echo $i | cut -d , -f 1`
237
+ user=`echo $i | cut -d , -f 2`
238
+ config_file=`echo $i | cut -d , -f 3`
239
+ if [ "$config_file" = "" ]; then
240
+ config_file="$dir/config/puma.rb"
241
+ fi
242
+ log_file=`echo $i | cut -d , -f 4`
243
+ if [ "$log_file" = "" ]; then
244
+ log_file="$dir/log/puma.log"
245
+ fi
246
+ do_start_one $dir $user $config_file $log_file
247
+ fi
248
+ case "$?" in
249
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
250
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
251
+ esac
252
+ ;;
253
+ stop)
254
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
255
+ if [ "$#" -eq 1 ]; then
256
+ do_stop
257
+ else
258
+ i=`grep $2 $CONFIG`
259
+ dir=`echo $i | cut -d , -f 1`
260
+ do_stop_one $dir
261
+ fi
262
+ case "$?" in
263
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
264
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
265
+ esac
266
+ ;;
267
+ status)
268
+ # TODO Implement.
269
+ log_daemon_msg "Status $DESC" "$NAME"
270
+ if [ "$#" -eq 1 ]; then
271
+ do_status
272
+ else
273
+ i=`grep $2 $CONFIG`
274
+ dir=`echo $i | cut -d , -f 1`
275
+ do_status_one $dir
276
+ fi
277
+ case "$?" in
278
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
279
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
280
+ esac
281
+ ;;
282
+ restart)
283
+ log_daemon_msg "Restarting $DESC" "$NAME"
284
+ if [ "$#" -eq 1 ]; then
285
+ do_restart
286
+ else
287
+ i=`grep $2 $CONFIG`
288
+ dir=`echo $i | cut -d , -f 1`
289
+ do_restart_one $dir
290
+ fi
291
+ case "$?" in
292
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
293
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
294
+ esac
295
+ ;;
296
+ add)
297
+ if [ "$#" -lt 3 ]; then
298
+ echo "Please, specifiy the app's directory and the user that will run it at least."
299
+ echo " Usage: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log"
300
+ echo " config and log are optionals."
301
+ exit 1
302
+ else
303
+ do_add $2 $3 $4 $5
304
+ fi
305
+ case "$?" in
306
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
307
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
308
+ esac
309
+ ;;
310
+ remove)
311
+ if [ "$#" -lt 2 ]; then
312
+ echo "Please, specifiy the app's directory to remove."
313
+ exit 1
314
+ else
315
+ do_remove $2
316
+ fi
317
+ case "$?" in
318
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
319
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
320
+ esac
321
+ ;;
322
+ *)
323
+ echo "Usage:" >&2
324
+ echo " Run the jungle: $SCRIPTNAME {start|stop|status|restart}" >&2
325
+ echo " Add a Puma: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log"
326
+ echo " config and log are optionals."
327
+ echo " Remove a Puma: $SCRIPTNAME remove /path/to/app"
328
+ echo " On a Puma: $SCRIPTNAME {start|stop|status|restart} PUMA-NAME" >&2
329
+ exit 3
330
+ ;;
331
+ esac
332
+ :
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ app=$1; config=$2; log=$3;
3
+ cd $app && exec bundle exec puma -C $config 2>&1 >> $log
@@ -0,0 +1,2 @@
1
+ production:
2
+ secret_key_base: <%= SecureRandom.hex %>
@@ -31,3 +31,33 @@ namespace :deploy do
31
31
  end
32
32
  end
33
33
  end
34
+
35
+
36
+ def smart_template(from, to=nil)
37
+ to ||= from
38
+ full_to_path = "#{shared_path}/config/#{to}"
39
+ if from_erb_path = template_file(from)
40
+ from_erb = StringIO.new(ERB.new(File.read(from_erb_path)).result(binding))
41
+ upload! from_erb, full_to_path
42
+ info "copying: #{from_erb} to: #{full_to_path}"
43
+ else
44
+ error "error #{from} not found"
45
+ end
46
+ end
47
+
48
+ def template_file(name)
49
+ if File.exist?((file = "config/deploy/#{fetch(:full_app_name)}/#{name}.erb"))
50
+ return file
51
+ elsif File.exist?((file = "config/deploy/shared/#{name}.erb"))
52
+ return file
53
+ end
54
+ return nil
55
+ end
56
+
57
+ def sub_strings(input_string)
58
+ output_string = input_string
59
+ input_string.scan(/{{(\w*)}}/).each do |var|
60
+ output_string.gsub!("{{#{var[0]}}}", fetch(var[0].to_sym))
61
+ end
62
+ output_string
63
+ end
@@ -1,3 +1,3 @@
1
1
  module Teleporter
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teleporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ponomarev Nikolay
@@ -70,14 +70,18 @@ files:
70
70
  - lib/generators/initial/gemfile.rb
71
71
  - lib/generators/initial/rspec_base.rb
72
72
  - lib/generators/initial/start.rb
73
- - lib/generators/initial/templates/capistrano/lib/substitute_strings.rb
74
- - lib/generators/initial/templates/capistrano/lib/template.rb
73
+ - lib/generators/initial/templates/capistrano/deploy/deploy.rb
74
+ - lib/generators/initial/templates/capistrano/deploy/production.rb
75
75
  - lib/generators/initial/templates/capistrano/shared/application.yml.erb
76
76
  - lib/generators/initial/templates/capistrano/shared/database.example.yml.erb
77
77
  - lib/generators/initial/templates/capistrano/shared/log_rotation.erb
78
78
  - lib/generators/initial/templates/capistrano/shared/monit.erb
79
79
  - lib/generators/initial/templates/capistrano/shared/monit_sidekiq.erb
80
80
  - lib/generators/initial/templates/capistrano/shared/nginx.conf.erb
81
+ - lib/generators/initial/templates/capistrano/shared/puma.conf.erb
82
+ - lib/generators/initial/templates/capistrano/shared/puma.erb
83
+ - lib/generators/initial/templates/capistrano/shared/run-puma.erb
84
+ - lib/generators/initial/templates/capistrano/shared/secrets.yml.erb
81
85
  - lib/generators/initial/templates/capistrano/shared/sidekiq.yml.erb
82
86
  - lib/generators/initial/templates/capistrano/shared/sidekiq_init.sh.erb
83
87
  - lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
@@ -85,7 +89,6 @@ files:
85
89
  - lib/generators/initial/templates/capistrano/tasks/check_revision.rake
86
90
  - lib/generators/initial/templates/capistrano/tasks/compile_assets_locally.rake
87
91
  - lib/generators/initial/templates/capistrano/tasks/logs.rake
88
- - lib/generators/initial/templates/capistrano/tasks/restart.rake
89
92
  - lib/generators/initial/templates/capistrano/tasks/setup_config.rake
90
93
  - lib/generators/initial/templates/rspec_base/configs/capybara.rb
91
94
  - lib/generators/initial/templates/rspec_base/configs/database_cleaner.rb
@@ -1,12 +0,0 @@
1
- # we often want to refer to variables which
2
- # are defined in subsequent stage files. This
3
- # let's us use the {{var}} to represent fetch(:var)
4
- # in strings which are only evaluated at runtime.
5
-
6
- def sub_strings(input_string)
7
- output_string = input_string
8
- input_string.scan(/{{(\w*)}}/).each do |var|
9
- output_string.gsub!("{{#{var[0]}}}", fetch(var[0].to_sym))
10
- end
11
- output_string
12
- end
@@ -1,32 +0,0 @@
1
- # will first try and copy the file:
2
- # config/deploy/#{full_app_name}/#{from}.erb
3
- # to:
4
- # shared/config/to
5
- # if the original source path doesn exist then it will
6
- # search in:
7
- # config/deploy/shared/#{from}.erb
8
- # this allows files which are common to all enviros to
9
- # come from a single source while allowing specific
10
- # ones to be over-ridden
11
- # if the target file name is the same as the source then
12
- # the second parameter can be left out
13
- def smart_template(from, to=nil)
14
- to ||= from
15
- full_to_path = "#{shared_path}/config/#{to}"
16
- if from_erb_path = template_file(from)
17
- from_erb = StringIO.new(ERB.new(File.read(from_erb_path)).result(binding))
18
- upload! from_erb, full_to_path
19
- info "copying: #{from_erb} to: #{full_to_path}"
20
- else
21
- error "error #{from} not found"
22
- end
23
- end
24
-
25
- def template_file(name)
26
- if File.exist?((file = "config/deploy/#{fetch(:full_app_name)}/#{name}.erb"))
27
- return file
28
- elsif File.exist?((file = "config/deploy/shared/#{name}.erb"))
29
- return file
30
- end
31
- return nil
32
- end
@@ -1,10 +0,0 @@
1
- namespace :deploy do
2
- desc 'Restart unicorn application'
3
- %w(start stop force-stop kill_worker restart upgrage reopen-logs).each do |command|
4
- task command.to_sym do
5
- on roles(:app), in: :sequence, wait: 5 do
6
- sudo "/etc/init.d/unicorn_#{fetch(:full_app_name)} #{command}"
7
- end
8
- end
9
- end
10
- end