taperole 1.0.1 → 1.1.0

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: 5016d666bbe3fbbbc52aec031ee02ea2ae60433e
4
- data.tar.gz: b388a0c99b4f8f13e7ba4611d2624c03358bb460
3
+ metadata.gz: 381889ad9f30af9db293aa6ce5399f4978349b1c
4
+ data.tar.gz: e5f37142b7d22ac0529bc676b6686b1ff14d4f3d
5
5
  SHA512:
6
- metadata.gz: e2a631378f974d3a66310aed8ed344dfd273eb720b1dd85c815099ba649f6b7125803e70a119197ca46bef21c322ad2b72adedaf6c9073401b0e139476c022d9
7
- data.tar.gz: 48dc9509d3ea930189935328a01f0ad573e840ce5aa7014dcc26d61657e1802dab9d93ed53a7da141aab8fbb19a329bad6647d6d8d1837c7fa49f0478572ab08
6
+ metadata.gz: aba42bab23247d0624fc0b9d03d3bb2e89007129bdf8e05d687b0d0efee9a38996226e6856f02f10457a69927eeadb4cb175ae68ff335e3948883d1ee6150788
7
+ data.tar.gz: 04b19dd30374fe2323c2bd4fb198a9ef96fd634728b1e121623f8dbf26c0caac61c4ab284078a23f37d2e8ca054f19aee48078056a056a762feeec328574e36c
@@ -7,7 +7,7 @@
7
7
  remote_user: "{{ deployer_user.name }}"
8
8
  command: chdir={{ be_app_path }}
9
9
  bash -lc "RAILS_ENV={{be_app_env}} bundle install
10
- --without test development contests_development --deployment"
10
+ --without test development --deployment"
11
11
  tags: [be_deploy, bundle]
12
12
 
13
13
  - name: Ensure env_config.yml file present
@@ -10,12 +10,3 @@
10
10
  when: (app_checkout is defined and app_checkout.changed)
11
11
  or rake.force_migrate
12
12
  or (db_reset is defined and db_reset.changed)
13
-
14
- - name: Seed DB
15
- remote_user: "{{ deployer_user.name }}"
16
- command: chdir={{ be_app_path }}
17
- bash -lc "bundle exec rake db:seed RAILS_ENV={{be_app_env}}"
18
- tags: [be_deploy,seed,db_reset]
19
- when: (app_checkout is defined and app_checkout.changed)
20
- or rake.force_seed
21
- or (db_reset is defined and db_reset.changed)
@@ -1,2 +1 @@
1
- ---
2
- force_dj_runner_restart: false
1
+ dj_runners: 2
@@ -0,0 +1,3 @@
1
+ ---
2
+ dependencies:
3
+ - role: zzet.rbenv
@@ -1,35 +1,24 @@
1
- - name: Install upstart job
2
- template: src=dj_runner_upstart.j2
3
- dest=/etc/init/dj_runner_{{app_name}}.conf
4
- tags: [configure_dj_runner]
5
- register: dj_runner_installation
6
- when: enabled_delayed_job
1
+ - name: Install DJ monit bin command
2
+ template: src=dj_monit_runner.j2
3
+ dest=/usr/bin/dj_monit_runner
4
+ mode=u=rwx,g=rwx,o=r
7
5
 
8
- - name: register unicorn upstart script
9
- command: initctl reload-configuration
10
- when: dj_runner_installation.changed and
11
- enabled_delayed_job
12
- tags: [configure_dj_runner]
6
+ - name: Install DJ monit config
7
+ template: src=dj_monit_config.j2
8
+ dest=/etc/monit/conf.d/delayed_jobs
9
+ mode=u=rw,g=r,o=r
10
+ register: dj_monit_config
13
11
 
14
- - name: Give deployer user access to DJ upstart jobs
15
- lineinfile: 'dest=/etc/sudoers
16
- state=present
17
- line="{{ deployer_user.name }} ALL = (root) NOPASSWD: /sbin/{{item}} dj_runner_{{app_name}}"'
18
- with_items:
19
- - start
20
- - stop
21
- - restart
22
- - status
23
- - reload
24
- tags: [configure_dj_runner]
25
- when: enabled_delayed_job
12
+ - name: Reload Monit
13
+ command: bash -lc "monit reload"
14
+ when: dj_monit_config.changed
26
15
 
27
- - name: restart delayed job runner
28
- sudo_upstart: name=dj_runner_{{app_name}} state=restarted
16
+ - name: Restart Delayed Job
29
17
  remote_user: "{{ deployer_user.name }}"
30
- when: force_dj_runner_restart or
31
- (dj_runner_installation is defined and dj_runner_installation.changed) or
32
- force_db_reset or
33
- (app_checkout is defined and app_checkout.changed) and
34
- enabled_delayed_job
35
- tags: [configure_dj_runner, be_deploy, reset_db]
18
+ command: bash -lc "sudo monit stop delayed_job"
19
+ tags: [be_deploy]
20
+
21
+ - name: Restart Delayed Job
22
+ remote_user: "{{ deployer_user.name }}"
23
+ command: bash -lc "sudo monit start delayed_job"
24
+ tags: [be_deploy]
@@ -0,0 +1,6 @@
1
+ check process delayed_job
2
+ with pidfile {{be_app_path}}/tmp/pids/delayed_job.pid
3
+ start program "/usr/bin/dj_monit_runner start {{dj_runners}}" as uid {{deployer_user.name}} and gid {{deployer_user.name}}
4
+ stop program "/usr/bin/dj_monit_runner stop" as uid {{deployer_user.name}} and gid {{deployer_user.name}}
5
+ if 5 restarts within 5 cycles then timeout
6
+ if totalmemory > 5 GB for 5 cycles then restart
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ USER={{deployer_user.name}}
4
+ APP_PATH={{be_app_path}}
5
+ PATH={{rbenv_root}}/bin:{{rbenv_root}}/shims:$PATH
6
+ RAILS_ENV={{be_app_env}}
7
+
8
+ cd $APP_PATH
9
+ RAILS_ENV=$RAILS_ENV bin/delayed_job $1 -n $2
data/taperole.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "taperole"
3
- spec.version = '1.0.1'
3
+ spec.version = '1.1.0'
4
4
  spec.authors = ['Jack Forrest', 'Smashing Boxes', 'Brandon Mathis']
5
5
  spec.email = ['jack@smashingboxes.com', 'brandon@sbox.es']
6
6
  spec.summary = 'A tool for provisioning and deploying boxes for hosting Rails apps'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taperole
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Forrest
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-03-22 00:00:00.000000000 Z
13
+ date: 2015-03-27 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description:
16
16
  email:
@@ -49,9 +49,10 @@ files:
49
49
  - roles/database_load/tasks/db_reset.yml
50
50
  - roles/database_load/tasks/main.yml
51
51
  - roles/delayed_job/defaults/main.yml
52
- - roles/delayed_job/library/sudo_upstart
52
+ - roles/delayed_job/meta/main.yml
53
53
  - roles/delayed_job/tasks/main.yml
54
- - roles/delayed_job/templates/dj_runner_upstart.j2
54
+ - roles/delayed_job/templates/dj_monit_config.j2
55
+ - roles/delayed_job/templates/dj_monit_runner.j2
55
56
  - roles/deployer_user/files/id_rsa_digital_ocean.pub
56
57
  - roles/deployer_user/tasks/keys.yml
57
58
  - roles/deployer_user/tasks/main.yml
@@ -219,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
220
  version: '0'
220
221
  requirements: []
221
222
  rubyforge_project:
222
- rubygems_version: 2.2.2
223
+ rubygems_version: 2.4.6
223
224
  signing_key:
224
225
  specification_version: 4
225
226
  summary: A tool for provisioning and deploying boxes for hosting Rails apps
@@ -1,101 +0,0 @@
1
- #!/bin/sh
2
-
3
- # This ansible module runs upstart tasks with sudo.
4
- # This is necessary when specific jobs are allowed with
5
- # the sudoers file, as using the ansible service module will
6
- # attempt to execute the entire service module as root instead
7
- # of just the /sbin/{start,stop,...} jobs
8
- #
9
- # This module also wraps restart and reload, ensuring the service
10
- # is started
11
-
12
- # Ansible provides its module opts in a file that needs to be sourced
13
- # to get the env we run in
14
- . $1
15
-
16
- # Avoid stalling on password prompts
17
- sudocmd="echo '' | sudo -S"
18
-
19
- # holds the result of our operations for reporting state changes
20
- res=none
21
-
22
- sudoex() { eval "$sudocmd $@ >/dev/null";}
23
-
24
- # Failure JSON that ansible expects
25
- fail() {
26
- echo '{"failed": true, "msg": "' $1 '", "status": "'`us_status $name`'"}'
27
- exit 1
28
- }
29
-
30
- # Make sure certain vars are set when sourcing $1
31
- require_opt() {
32
- eval val=\$$1
33
- if [ ! -n "$val" ]; then
34
- fail "Opt: $1 is required!"
35
- fi
36
- }
37
-
38
- # All we need for now is name and state
39
- require_opt name
40
- require_opt state
41
-
42
- if ! status $name; then
43
- fail "Invalid service: $name"
44
- fi
45
-
46
- reload() {
47
- if sudoex /sbin/reload $name; then
48
- res=reloaded
49
- else
50
- sudoex /sbin/start $name || fail "Could not reload or start! $name"
51
- res=started
52
- fi
53
- }
54
-
55
- restart() {
56
- if sudoex /sbin/restart $name; then
57
- res=restarted
58
- else
59
- sudoex /sbin/start $name || fail "Could not restart or start! $name"
60
- res=started
61
- fi
62
- }
63
-
64
- stopit() {
65
- if [ "`us_status $name`" = "stop/waiting" ]; then
66
- res=none
67
- else
68
- sudoex /sbin/stop $name || fail "Could not stop $name"
69
- res=stopped
70
- fi
71
- }
72
-
73
- start() {
74
- if [ "`us_status $name`" = "start/running" ]; then
75
- res=none
76
- else
77
- sudoex /sbin/start $name || fail "Could not start $name"
78
- res=started
79
- fi
80
- }
81
-
82
- # Return status string for the given service
83
- us_status() {
84
- status $1 | cut -f 2 -d ' ' | tr -d ','
85
- }
86
-
87
- res=''
88
- case $state in
89
- reloaded) reload;;
90
- restarted) restart;;
91
- stopped) stopit;;
92
- started) start;;
93
- *) fail "Invalid state: $state";;
94
- esac
95
-
96
- # Were there changes applied?
97
- if [ "$res" = none ]; then
98
- echo '{"changed": false}'
99
- else
100
- echo '{"change": "'$res'", "changed": true}'
101
- fi
@@ -1,17 +0,0 @@
1
- description "{{app_name}} delayed job runner daemon"
2
-
3
- start on virtual-filesystems
4
- stop on runlevel [06]
5
-
6
- env PATH={{ rbenv_root }}/shims:{{ rbenv_root }}/bin:/usr/bin:/sbin:/bin
7
- env RAILS_ENV={{be_app_env}}
8
- setuid {{ deployer_user.name }}
9
- setgid {{ deployer_user.name }}
10
-
11
- chdir {{be_app_path}}
12
-
13
- respawn limit 5 5
14
-
15
- kill timeout 5
16
-
17
- exec bundle exec bin/delayed_job run