daddy 0.2.14 → 0.2.15

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: b17b97a68f169215e11b94bdf84083b1418e62c9
4
- data.tar.gz: 465b880657f3de549b3458c9f11b23bb90cc94b9
3
+ metadata.gz: cd6a94ac7baeaaec00d5ec791de338eeb162d51b
4
+ data.tar.gz: 788cb084e3a647ba30b9e837bddc1e9def26f874
5
5
  SHA512:
6
- metadata.gz: bf2079d6e138e81db0a9e106ceda8934a8713abb17bfd1e2ebcf9dacbd88443fef9499d09c331d0a8ed64e7458cd978794de9f1dfc1ed93787922a70b9b3b625
7
- data.tar.gz: fe3b744bee7381d46364d6b7e88ff8c00f1ef34818a5cbac98a3926ec96a544ad8747901a9a1bb9047ab832e0b5111600ee65461f589dc64c216a41a6920cab7
6
+ metadata.gz: 30d845baa18b8b9246d5ef9d221eb56cdec50acd4af0cc2138ef11d9aa647647bf2be0c5c2a849739c38fce2f6b187b89b7e583270318aa60d434a2176be3b18
7
+ data.tar.gz: 3f1c7665340961c4bf0223d9bb6f38272560641d9762b5f54bd9511499e8809876e736d3e0ed1264d04aab182178794d2d90ee299403860d3aa063bad86b95d6
@@ -1,5 +1,3 @@
1
- # coding: UTF-8
2
-
3
1
  module Daddy
4
2
  module Models
5
3
 
@@ -1,5 +1,3 @@
1
- # coding: UTF-8
2
-
3
1
  require 'rake'
4
2
 
5
3
  namespace :dad do
@@ -7,31 +5,8 @@ namespace :dad do
7
5
 
8
6
  desc "Godをインストールします。"
9
7
  task :install do
10
- script = <<-EOF
11
- #!/bin/bash
12
-
13
- if [ -e /var/run/god.pid ]; then
14
- sudo /etc/init.d/god stop
15
- fi
16
-
17
- sudo gem install god
18
- sudo mkdir -p /etc/god
19
-
20
- sudo cp -f #{File.join(File.dirname(__FILE__), 'god')} /etc/init.d/god
21
- sudo chown root:root /etc/init.d/god
22
- sudo chmod 755 /etc/init.d/god
23
-
24
- sudo cp -f #{File.join(File.dirname(__FILE__), 'god.logrotate')} /etc/logrotate.d/god
25
- sudo chown root:root /etc/logrotate.d/god
26
- sudo chmod 644 /etc/logrotate.d/god
27
-
28
- sudo /sbin/chkconfig god on
29
- sudo /etc/init.d/god start
30
- EOF
31
-
32
- tmpfile = File.join(Rails.root, 'tmp', 'dad-god-install-' + Daddy::Utils::StringUtils.current_time + '.sh')
33
- File.write(tmpfile, ERB.new(script).result)
34
- fail unless system("bash #{tmpfile}")
8
+ script = File.join(File.dirname(__FILE__), 'god', 'install.sh')
9
+ system("bash -x #{script} #{rails_env} #{rails_root}")
35
10
  end
36
11
 
37
12
  end
@@ -6,33 +6,30 @@
6
6
  # description: god monitors your system
7
7
  #
8
8
 
9
- CONFIG_FILES=/etc/god/*.god
10
9
  PID=/var/run/god.pid
10
+ CONFIG=/etc/god/master.conf
11
11
  LOG=/var/log/god.log
12
- PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
12
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
13
13
  RETVAL=0
14
14
 
15
15
  case "$1" in
16
16
  start)
17
- god -P $PID -l $LOG --log-level info
18
- for config in $CONFIG_FILES; do
19
- god load $config
20
- done
17
+ echo 'Starting god'
18
+ god -P $PID -c $CONFIG -l $LOG --log-level info
21
19
  RETVAL=$?
22
20
  ;;
23
21
  stop)
24
- kill `cat $PID`
22
+ god quit
25
23
  RETVAL=$?
26
24
  ;;
27
25
  restart)
28
- kill `cat $PID`
29
- god -P $PID -l $LOG --log-level info
30
- for config in $CONFIG_FILES; do
31
- god load $config
32
- done
26
+ god quit
27
+ echo 'Starting god'
28
+ god -P $PID -c $CONFIG -l $LOG --log-level info
33
29
  RETVAL=$?
34
30
  ;;
35
31
  status)
32
+ god status
36
33
  RETVAL=$?
37
34
  ;;
38
35
  *)
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+
3
+ SCRIPT_BASE=`dirname $0`
4
+ export RAILS_ENV=$1
5
+ export RAILS_ROOT=$2
6
+
7
+ # stop god
8
+ if [ -e /var/run/god.pid ]; then
9
+ sudo /etc/init.d/god stop
10
+ fi
11
+
12
+ # install
13
+ sudo gem install god --no-ri --no-rdoc
14
+
15
+ # init.d
16
+ sudo cp -f ${SCRIPT_BASE}/god /etc/init.d/god
17
+ sudo chown root:root /etc/init.d/god
18
+ sudo chmod 755 /etc/init.d/god
19
+
20
+ # master.conf
21
+ sudo mkdir -p /etc/god
22
+ sudo cp -f ${SCRIPT_BASE}/master.conf /etc/god/master.conf
23
+ sudo chown root:root /etc/god/master.conf
24
+ sudo chmod 644 /etc/god/master.conf
25
+
26
+ # logrotate
27
+ sudo cp -f ${SCRIPT_BASE}/logrotate /etc/logrotate.d/god
28
+ sudo chown root:root /etc/logrotate.d/god
29
+ sudo chmod 644 /etc/logrotate.d/god
30
+
31
+ # service
32
+ sudo /sbin/chkconfig god on
33
+
34
+ # start
35
+ sudo /etc/init.d/god start
@@ -0,0 +1,3 @@
1
+ Dir.glob("/etc/god/*.god").each do |app_config|
2
+ load app_config
3
+ end
@@ -5,6 +5,10 @@ def self.rails_root
5
5
  ENV['RAILS_ROOT'] || Rails.root
6
6
  end
7
7
 
8
+ def self.rails_env
9
+ ENV['RAILS_ENV'] || 'development'
10
+ end
11
+
8
12
  def self.app_name
9
13
  YAML.load_file("#{rails_root}/config/database.yml")[Rails.env]['database']
10
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -366,10 +366,11 @@ files:
366
366
  - lib/tasks/generate/templates/routes.rb.erb
367
367
  - lib/tasks/generate/templates/show.html.erb
368
368
  - lib/tasks/generate/view.rake
369
- - lib/tasks/god
370
- - lib/tasks/god.logrotate
371
369
  - lib/tasks/god.rake
372
- - lib/tasks/install.sh
370
+ - lib/tasks/god/god
371
+ - lib/tasks/god/install.sh
372
+ - lib/tasks/god/logrotate
373
+ - lib/tasks/god/master.conf
373
374
  - lib/tasks/jenkins
374
375
  - lib/tasks/jenkins.conf
375
376
  - lib/tasks/jenkins.rake
@@ -1,45 +0,0 @@
1
- #!/bin/bash
2
-
3
- echo "既にGodが起動していたら停止します。"
4
- if [ -e /var/run/god.pid ]; then
5
- sudo /etc/init.d/god stop
6
- fi
7
-
8
- echo "Godをインストールします。"
9
- sudo gem install god
10
-
11
- echo "Godの起動スクリプトを /etc/init.d/god に配置します。"
12
- sudo cp -f script/god/god /etc/init.d/god
13
- sudo chown root:root /etc/init.d/god
14
- sudo chmod 755 /etc/init.d/god
15
-
16
- echo "Godの設定ファイルを /etc/god/madai.god に配置します。"
17
- export RAILS_ENV=$1
18
- export RAILS_ROOT=$2
19
-
20
- sudo mkdir -p /etc/god
21
- erb -T - script/god/madai.god.erb > tmp/madai.god
22
- sudo cp -f tmp/madai.god /etc/god/madai.god
23
- sudo chown -R root:root /etc/god
24
- sudo chmod 755 /etc/god
25
- sudo chmod -R 644 /etc/god/*
26
-
27
- unset RAILS_ENV
28
- unset RAILS_ROOT
29
-
30
- echo "Godのログロテート設定を /etc/logrotate.d/god に配置します。"
31
- sudo cp -f script/god/logrotate /etc/logrotate.d/god
32
- sudo chown root:root /etc/logrotate.d/god
33
- sudo chmod 644 /etc/logrotate.d/god
34
-
35
- echo "サービスの自動起動設定を行います。"
36
- sudo /sbin/chkconfig god on
37
-
38
- echo "Godを起動します。"
39
- if [ -z ${NO_START} ]; then
40
- NO_START=0
41
- fi
42
-
43
- if [ ${NO_START} -ne 1 ]; then
44
- sudo /etc/init.d/god start
45
- fi