teleporter 2.0.8 → 2.0.9

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: bcc38e9903c5b8c866c8b05705b2b9cea223c8ea
4
- data.tar.gz: 15d99df82341dd8f30ae437e637a516ecf349dbd
3
+ metadata.gz: d3c07445ab18be348fd3f3ccbd82b248f5d654c5
4
+ data.tar.gz: ba980322715f1acc0dcfd6770107eb2e54df1b8a
5
5
  SHA512:
6
- metadata.gz: ebf3eb53f850d6cd0134d0f75e096425b457a156cc15fa280bf2e1c50d09860f89f5ed33b8eacafbd47ea1d23447ab433906ef703a5392dec9e59a9a2e12bd4f
7
- data.tar.gz: 577e5e1f3d721c7795a8374814f6627e4dcd565d9a0fd8f89bc7bd5e961d3b969300c6482d66c48b2566e9643fec100f36e9012d6adbbb24b95b9aa92391f2eb
6
+ metadata.gz: a9aa894358360582d1624a89872260087bfde9c1cabf5be239fe1db34c335343b41893592f6b4c8f4b6407ede5a6efb896df76c7fdb87afa99b23ffcd3b23ac1
7
+ data.tar.gz: 43e4ea96d0b4bc804043c922f2198e809a81a515df76b3ccf7494fc990622066fdf26f9957656582aa9866e8fde0145a259d1f15ad6c7cae7412449f186ad59b
@@ -9,7 +9,7 @@ module Teleport
9
9
  gem 'capistrano-bundler'
10
10
  gem 'capistrano-rails'
11
11
  gem 'capistrano-sidekiq'
12
- gem 'capistrano3-puma'
12
+ gem 'capistrano3-puma', github: 'itsNikolay/capistrano-puma', branch: 'puma_monit_namespace'
13
13
  end
14
14
 
15
15
  Bundler.with_clean_env do
@@ -2,6 +2,7 @@ lock '3.2.1'
2
2
 
3
3
  set :repo_url, '<%= @git_repo_url %>'
4
4
  set :application, '<%= @app_name %>'
5
+ set :deploy_to, -> { "/home/#{fetch(:deploy_user)}/apps/#{fetch(:application)}_#{fetch(:stage)}" }
5
6
 
6
7
  set :puma_init_active_record, true
7
8
  set :puma_preload_app, false
@@ -1,7 +1,6 @@
1
1
  set :stage, :production
2
2
  set :rails_env, :production
3
3
  set :branch, "master"
4
- set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:application)}_#{fetch(:stage)}"
5
4
  set :deploy_user, '<%= @deploy_user %>'
6
5
  set :ip, '<%= @production_server_address %>'
7
6
 
@@ -1,7 +1,6 @@
1
1
  set :stage, :staging
2
2
  set :rails_env, :staging
3
3
  set :branch, "master"
4
- set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:application)}_#{fetch(:stage)}"
5
4
  set :deploy_user, '<%= @deploy_user %>'
6
5
  set :ip, '<%= @staging_server_address %>'
7
6
 
@@ -1,11 +1,10 @@
1
- <% application = fetch(:application) %>
2
- set mail-format { subject: <%= "#{fetch(:full_app_name)} - #{fetch(:rails_env)}" %> $SERVICE $EVENT at $DATE }
1
+ set mail-format { subject: <%= "#{fetch(:application)} - #{fetch(:stage)}" %> $SERVICE $EVENT at $DATE }
3
2
 
4
- check process sidekiq
3
+ check process <%= fetch(:application) %>_<%= fetch(:stage) %>
5
4
  with pidfile <%= current_path %>/tmp/pids/sidekiq.pid
6
- start program = "/etc/init.d/sidekiq_<%= application %>_<%= fetch(:rails_env)%> start"
7
- stop program = "/etc/init.d/sidekiq_<%= application %>_<%= fetch(:rails_env)%> stop"
5
+ start program = "/etc/init.d/sidekiq_<%= fetch(:application) %>_<%= fetch(:stage)%> start"
6
+ stop program = "/etc/init.d/sidekiq_<%= fetch(:application) %>_<%= fetch(:stage)%> stop"
8
7
  if mem is greater than 500.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?
8
+ if cpu is greater than 50% for 2 cycles then alert # send an email to admin
9
+ if cpu is greater than 80% for 30 cycles then restart # hung process?
11
10
  group sidekiq
@@ -12,20 +12,21 @@ namespace :deploy do
12
12
  set(:symlinks, [
13
13
  {
14
14
  source: "log_rotation",
15
- link: "/etc/logrotate.d/{{application}}"
15
+ link: "/etc/logrotate.d/{{application}}_{{stage}}"
16
16
  },
17
17
  {
18
18
  source: "monit_sidekiq",
19
- link: "/etc/monit/conf.d/sidekiq_{{application}}.conf"
19
+ link: "/etc/monit/conf.d/sidekiq_{{application}}_{{stage}}.conf"
20
20
  },
21
21
  {
22
22
  source: "sidekiq_init.sh",
23
- link: "/etc/init.d/sidekiq_{{application}}"
23
+ link: "/etc/init.d/sidekiq_{{application}}_{{stage}}"
24
24
  },
25
25
  ])
26
26
  execute :mkdir, "-p #{shared_path}/config"
27
27
  execute :mkdir, "-p #{current_path}"
28
28
  application = fetch(:application)
29
+ stage = fetch(:stage)
29
30
 
30
31
  config_files = fetch(:config_files)
31
32
  config_files.each do |file|
@@ -1,3 +1,3 @@
1
1
  module Teleporter
2
- VERSION = "2.0.8"
2
+ VERSION = "2.0.9"
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: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ponomarev Nikolay
@@ -104,16 +104,8 @@ files:
104
104
  - lib/generators/teleport/templates/capistrano/deploy/deploy.rb.tt
105
105
  - lib/generators/teleport/templates/capistrano/deploy/production.rb.tt
106
106
  - lib/generators/teleport/templates/capistrano/deploy/staging.rb.tt
107
- - lib/generators/teleport/templates/capistrano/shared/database.example.yml.erb
108
107
  - lib/generators/teleport/templates/capistrano/shared/log_rotation.erb
109
- - lib/generators/teleport/templates/capistrano/shared/monit.erb
110
108
  - lib/generators/teleport/templates/capistrano/shared/monit_sidekiq.erb
111
- - lib/generators/teleport/templates/capistrano/shared/nginx.conf.erb
112
- - lib/generators/teleport/templates/capistrano/shared/puma.conf.erb
113
- - lib/generators/teleport/templates/capistrano/shared/puma.erb
114
- - lib/generators/teleport/templates/capistrano/shared/puma.rb.erb
115
- - lib/generators/teleport/templates/capistrano/shared/run-puma.erb
116
- - lib/generators/teleport/templates/capistrano/shared/sidekiq.yml.erb
117
109
  - lib/generators/teleport/templates/capistrano/shared/sidekiq_init.sh.erb
118
110
  - lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
119
111
  - lib/generators/teleport/templates/capistrano/shared/unicorn_init.sh.erb
@@ -1,11 +0,0 @@
1
- <%= fetch(:rails_env) %>:
2
- adapter: postgresql
3
- timeout: 5000
4
- encoding: utf8
5
- reconnect: false
6
- database: <%= "#{fetch(:application)}_#{fetch(:rails_env)}" %>
7
- pool: 5
8
- username: <%= "#{fetch(:deploy_user)}" %>
9
- password: secret
10
- host:
11
- port: 5432
@@ -1,7 +0,0 @@
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,55 +0,0 @@
1
- upstream puma {
2
- server unix:/<%= fetch(:deploy_to) %>/shared/tmp/sockets/puma.sock fail_timeout=0;
3
- }
4
-
5
- server {
6
- listen 80 default deferred;
7
- root <%= fetch(:deploy_to) %>/current/public;
8
-
9
- location ^~ /assets/ {
10
- gzip_static on;
11
- expires max;
12
- add_header Cache-Control public;
13
- }
14
-
15
- try_files $uri/index.html $uri @puma;
16
- location @puma {
17
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
18
- proxy_set_header Host $http_host;
19
- proxy_redirect off;
20
- proxy_pass http://puma;
21
- }
22
-
23
- error_page 500 502 503 504 /500.html;
24
- client_max_body_size 4G;
25
- keepalive_timeout 10;
26
- }
27
-
28
- <% if fetch(:enable_ssl) %>
29
- server {
30
- listen 443 default deferred;
31
- root <%= fetch(:deploy_to) %>/current/public;
32
-
33
- location ^~ /assets/ {
34
- gzip_static on;
35
- expires max;
36
- add_header Cache-Control public;
37
- }
38
-
39
- try_files $uri/index.html $uri @puma;
40
- location @puma {
41
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
42
- proxy_set_header X-Forwarded-Proto https;
43
- proxy_set_header Host $http_host;
44
- proxy_redirect off;
45
- proxy_pass http://puma;
46
- }
47
-
48
- error_page 500 502 503 504 /500.html;
49
- client_max_body_size 4G;
50
- keepalive_timeout 10;
51
- ssl on;
52
- ssl_certificate <%= fetch(:deploy_to) %>/shared/ssl_cert.crt;
53
- ssl_certificate_key <%= fetch(:deploy_to) %>/shared/ssl_private_key.key;
54
- }#
55
- <% end %>
@@ -1 +0,0 @@
1
- <%= current_path %>,<%= fetch(:deploy_user) %>
@@ -1,332 +0,0 @@
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
- :
@@ -1,18 +0,0 @@
1
- workers Integer(ENV['PUMA_WORKERS'] || 3)
2
- threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
3
-
4
- preload_app!
5
-
6
- rackup DefaultRackup
7
- port ENV['PORT'] || 3000
8
- environment ENV['RACK_ENV'] || 'development'
9
-
10
- on_worker_boot do
11
- # worker specific setup
12
- ActiveSupport.on_load(:active_record) do
13
- config = ActiveRecord::Base.configurations[Rails.env] ||
14
- Rails.application.config.database_configuration[Rails.env]
15
- config['pool'] = ENV['MAX_THREADS'] || 16
16
- ActiveRecord::Base.establish_connection(config)
17
- end
18
- end
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
- app=$1; config=$2; log=$3;
3
- cd $app && exec bundle exec puma -C $config 2>&1 >> $log
@@ -1,3 +0,0 @@
1
- concurrency: 1
2
- <%= fetch(:rails_env) %>:
3
- pidfile: tmp/pids/sidekiq.pid