openteam-commons 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/openteam_commons/install/install_generator.rb +2 -4
- data/lib/generators/openteam_commons/install/templates/config/directories.rb +40 -0
- data/lib/generators/openteam_commons/install/templates/config/schedule.rb +6 -2
- data/lib/generators/openteam_commons/install/templates/config/unicorn.rb +17 -34
- data/lib/openteam-commons/version.rb +1 -1
- metadata +15 -14
@@ -12,13 +12,11 @@ module OpenteamCommons
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def create_libs
|
15
|
-
|
15
|
+
directory 'lib'
|
16
16
|
end
|
17
17
|
|
18
18
|
def create_configs
|
19
|
-
|
20
|
-
copy_file 'config/settings.yml.example'
|
21
|
-
copy_file 'config/unicorn.rb'
|
19
|
+
directory 'config'
|
22
20
|
copy_file 'Procfile'
|
23
21
|
end
|
24
22
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Directories
|
2
|
+
def root
|
3
|
+
@root ||= File.expand_path('../..', __FILE__)
|
4
|
+
end
|
5
|
+
|
6
|
+
def group
|
7
|
+
@group ||= root.split('/')[-2]
|
8
|
+
end
|
9
|
+
|
10
|
+
def project
|
11
|
+
@project ||= root.split('/')[-1]
|
12
|
+
end
|
13
|
+
|
14
|
+
def config(file=nil)
|
15
|
+
"#{root}/config/#{file}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def log(file=nil)
|
19
|
+
@log_dir ||= begin
|
20
|
+
FileUtils.mkdir_p("/var/log/#{group}/#{project}")
|
21
|
+
"/var/log/#{group}/#{project}/#{file}"
|
22
|
+
rescue Errno::EACCES
|
23
|
+
"#{root}/log/#{file}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def pid_file
|
28
|
+
@pid_file ||= begin
|
29
|
+
FileUtils.mkdir_p("/var/run/#{group}")
|
30
|
+
p "/var/run/#{group}/#{project}.pid"
|
31
|
+
rescue Errno::EACCES
|
32
|
+
p "/tmp/#{group}-#{project}.pid"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def heroku?
|
37
|
+
ENV['PORT']
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
require File.expand_path('../directories.rb', __FILE__)
|
2
|
+
|
3
|
+
dir = Directories.new
|
4
|
+
|
1
5
|
if RUBY_PLATFORM =~ /freebsd/
|
2
|
-
set :job_template, "/usr/local/bin/bash -l -i -c ':job'"
|
6
|
+
set :job_template, "/usr/local/bin/bash -l -i -c ':job' 1>#{dir.log('schedule.log')} 2>#{dir.log('schedule-errors.log')}"
|
3
7
|
else
|
4
|
-
set :job_template, "/bin/bash -l -i -c ':job'"
|
8
|
+
set :job_template, "/bin/bash -l -i -c ':job' 1>#{dir.log('schedule.log')} 2>#{dir.log('schedule-errors.log')}"
|
5
9
|
end
|
6
10
|
|
7
11
|
every :day do
|
@@ -1,52 +1,35 @@
|
|
1
|
-
|
2
|
-
File.expand_path('../..', __FILE__)
|
3
|
-
end
|
1
|
+
require File.expand_path('../directories.rb', __FILE__)
|
4
2
|
|
5
|
-
|
6
|
-
current_dir.split('/')[-2]
|
7
|
-
end
|
3
|
+
dir = Directories.new
|
8
4
|
|
9
|
-
def
|
10
|
-
|
5
|
+
def dir.settings
|
6
|
+
heroku? ? {} : (YAML.load_file(config('settings.yml'))['unicorn'] || {})
|
11
7
|
end
|
12
|
-
|
13
|
-
|
14
|
-
"#{current_dir}/config/settings.yml"
|
8
|
+
def dir.old_pid
|
9
|
+
"#{pid_file}.oldbin"
|
15
10
|
end
|
16
11
|
|
17
|
-
def heroku?
|
18
|
-
ENV['PORT']
|
19
|
-
end
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def pid_file
|
26
|
-
heroku? ? "/tmp/#{group}-#{project}.pid" : "/var/run/#{group}/#{project}.pid"
|
27
|
-
end
|
28
|
-
|
29
|
-
worker_processes (settings['workers'] || ENV['UNICORN_WORKERS'] || 2).to_i
|
30
|
-
timeout (settings['timeout'] || ENV['UNICORN_TIMEOUT'] || 300).to_i
|
13
|
+
worker_processes (dir.settings['workers'] || ENV['UNICORN_WORKERS'] || 2).to_i
|
14
|
+
timeout (dir.settings['timeout'] || ENV['UNICORN_TIMEOUT'] || 300).to_i
|
31
15
|
preload_app true
|
32
|
-
pid pid_file
|
16
|
+
pid dir.pid_file
|
17
|
+
|
18
|
+
listen ENV['PORT'].to_i, :tcp_nopush => false if ENV['PORT'].to_i > 0
|
33
19
|
|
34
|
-
|
35
|
-
listen
|
36
|
-
else
|
37
|
-
listen "/tmp/#{group}-#{project}.sock", :backlog => 64
|
20
|
+
unless dir.heroku?
|
21
|
+
listen "/tmp/#{dir.group}-#{dir.project}.sock", :backlog => 64
|
38
22
|
|
39
|
-
stdout_path
|
40
|
-
stderr_path
|
23
|
+
stdout_path dir.log('stdout.log')
|
24
|
+
stderr_path dir.log('stderr.log')
|
41
25
|
end
|
42
26
|
|
43
27
|
before_fork do |server, worker|
|
44
28
|
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
45
29
|
|
46
|
-
old_pid
|
47
|
-
if File.exists?(old_pid) && server.pid != old_pid
|
30
|
+
if File.exists?(dir.old_pid) && server.pid != dir.old_pid
|
48
31
|
begin
|
49
|
-
Process.kill("QUIT", File.read(old_pid).to_i)
|
32
|
+
Process.kill("QUIT", File.read(dir.old_pid).to_i)
|
50
33
|
rescue Errno::ENOENT, Errno::ESRCH
|
51
34
|
# someone else did our job for us
|
52
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openteam-commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: airbrake
|
16
|
-
requirement: &
|
16
|
+
requirement: &11580300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11580300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: configliere
|
27
|
-
requirement: &
|
27
|
+
requirement: &11577240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *11577240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &11596380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *11596380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: whenever
|
49
|
-
requirement: &
|
49
|
+
requirement: &11592740 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *11592740
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: unicorn
|
60
|
-
requirement: &
|
60
|
+
requirement: &11259500 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *11259500
|
69
69
|
description: Description of OpenteamCommons.
|
70
70
|
email:
|
71
71
|
- mail@openteam.ru
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/generators/openteam_commons/install/templates/config/unicorn.rb
|
81
81
|
- lib/generators/openteam_commons/install/templates/config/settings.yml.example
|
82
82
|
- lib/generators/openteam_commons/install/templates/config/schedule.rb
|
83
|
+
- lib/generators/openteam_commons/install/templates/config/directories.rb
|
83
84
|
- lib/generators/openteam_commons/install/templates/Procfile
|
84
85
|
- lib/generators/openteam_commons/install/templates/script/update_site
|
85
86
|
- lib/generators/openteam_commons/install/templates/script/start_site
|
@@ -103,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
104
|
version: '0'
|
104
105
|
segments:
|
105
106
|
- 0
|
106
|
-
hash:
|
107
|
+
hash: 3825267558657801059
|
107
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
109
|
none: false
|
109
110
|
requirements:
|
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
113
|
version: '0'
|
113
114
|
segments:
|
114
115
|
- 0
|
115
|
-
hash:
|
116
|
+
hash: 3825267558657801059
|
116
117
|
requirements: []
|
117
118
|
rubyforge_project:
|
118
119
|
rubygems_version: 1.8.15
|