openteam-commons 0.2.4 → 0.2.5
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 +4 -4
- data/README.rdoc +2 -2
- data/lib/openteam-commons.rb +1 -1
- data/lib/openteam-commons/engine.rb +25 -17
- data/lib/openteam-commons/version.rb +1 -1
- metadata +3 -13
- data/config/initializers/sunspot.rb +0 -6
- data/lib/generators/openteam_commons/install/install_generator.rb +0 -25
- data/lib/generators/openteam_commons/install/templates/Procfile +0 -1
- data/lib/generators/openteam_commons/install/templates/config/directories.rb +0 -39
- data/lib/generators/openteam_commons/install/templates/config/schedule.rb +0 -13
- data/lib/generators/openteam_commons/install/templates/config/settings.yml.example +0 -21
- data/lib/generators/openteam_commons/install/templates/config/unicorn.rb +0 -41
- data/lib/generators/openteam_commons/install/templates/lib/tasks/cron.rake +0 -2
- data/lib/generators/openteam_commons/install/templates/script/start_site +0 -11
- data/lib/generators/openteam_commons/install/templates/script/update_site +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c27aa4d8670ed7035e5a4bc002cf5bae27baccf0
|
4
|
+
data.tar.gz: 2c056e09846d60f095ca7782e9fd15c4afbd56fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3521b6461ddb14e7048e5864f4ec60870e39e4c088f1e850f7afc6f9bb0d4ddb73dc046f7edfb6131334ebade680254486f33ee5cc472bca0230f24cba9cd79c
|
7
|
+
data.tar.gz: 7e9da3485c3efba9fc357068ad455759f1a3a321e2b85c3057f65356563afe2e43c840a26d3338b81a498358ba1084d29d39456dc26ef20fd140ea3048eb77ae
|
data/README.rdoc
CHANGED
data/lib/openteam-commons.rb
CHANGED
@@ -12,7 +12,7 @@ module OpenteamCommons
|
|
12
12
|
config.after_initialize do
|
13
13
|
setup_airbrake
|
14
14
|
setup_locale
|
15
|
-
setup_secret
|
15
|
+
setup_secret if Rails.version.to_f < 4.1
|
16
16
|
end
|
17
17
|
|
18
18
|
def read_settings
|
@@ -21,32 +21,40 @@ module OpenteamCommons
|
|
21
21
|
Settings.defaults Settings.extract!(Rails.env)[Rails.env] || {}
|
22
22
|
Settings.extract!(:test, :development, :production)
|
23
23
|
|
24
|
-
Settings.define 'amqp.url', :
|
24
|
+
Settings.define 'amqp.url', env_var: 'AMQP_URL'
|
25
25
|
|
26
|
-
Settings.define 'app.secret', :
|
27
|
-
Settings.define 'app.url', :
|
26
|
+
Settings.define 'app.secret', env_var: 'APP_SECRET'
|
27
|
+
Settings.define 'app.url', env_var: 'APP_URL'
|
28
28
|
|
29
|
-
Settings.define 'errors.key', :
|
30
|
-
Settings.define 'errors.url', :
|
29
|
+
Settings.define 'errors.key', env_var: 'ERRORS_KEY'
|
30
|
+
Settings.define 'errors.url', env_var: 'ERRORS_URL'
|
31
31
|
|
32
|
-
Settings.define 'solr.url', :
|
32
|
+
Settings.define 'solr.url', env_var: 'SOLR_URL'
|
33
33
|
|
34
|
-
Settings.define 'sso.key', :
|
35
|
-
Settings.define 'sso.secret', :
|
36
|
-
Settings.define 'sso.url', :
|
34
|
+
Settings.define 'sso.key', env_var: 'SSO_KEY'
|
35
|
+
Settings.define 'sso.secret', env_var: 'SSO_SECRET'
|
36
|
+
Settings.define 'sso.url', env_var: 'SSO_URL'
|
37
37
|
|
38
|
-
Settings.define 'storage.url', :
|
38
|
+
Settings.define 'storage.url', env_var: 'STORAGE_URL'
|
39
39
|
end
|
40
40
|
|
41
41
|
def setup_airbrake
|
42
42
|
if Settings['errors.key'].present?
|
43
|
-
Airbrake.
|
44
|
-
|
43
|
+
if Airbrake::AIRBRAKE_VERSION.to_i < 4
|
44
|
+
Airbrake.configure do |config|
|
45
|
+
config.api_key = Settings['errors.key']
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
URI.parse(Settings['errors.url']).tap do |url|
|
48
|
+
config.host = url.host
|
49
|
+
config.port = url.port
|
50
|
+
config.secure = url.scheme.inquiry.https?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
else
|
54
|
+
Airbrake.configure do |config|
|
55
|
+
config.project_key = Settings['errors.key']
|
56
|
+
config.project_id = -1
|
57
|
+
config.host = Settings['errors.url']
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openteam-commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTeam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake
|
@@ -90,17 +90,7 @@ files:
|
|
90
90
|
- MIT-LICENSE
|
91
91
|
- README.rdoc
|
92
92
|
- Rakefile
|
93
|
-
- config/initializers/sunspot.rb
|
94
93
|
- config/locales/datetime.ru.yml
|
95
|
-
- lib/generators/openteam_commons/install/install_generator.rb
|
96
|
-
- lib/generators/openteam_commons/install/templates/Procfile
|
97
|
-
- lib/generators/openteam_commons/install/templates/config/directories.rb
|
98
|
-
- lib/generators/openteam_commons/install/templates/config/schedule.rb
|
99
|
-
- lib/generators/openteam_commons/install/templates/config/settings.yml.example
|
100
|
-
- lib/generators/openteam_commons/install/templates/config/unicorn.rb
|
101
|
-
- lib/generators/openteam_commons/install/templates/lib/tasks/cron.rake
|
102
|
-
- lib/generators/openteam_commons/install/templates/script/start_site
|
103
|
-
- lib/generators/openteam_commons/install/templates/script/update_site
|
104
94
|
- lib/openteam-commons.rb
|
105
95
|
- lib/openteam-commons/engine.rb
|
106
96
|
- lib/openteam-commons/version.rb
|
@@ -123,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
113
|
version: '0'
|
124
114
|
requirements: []
|
125
115
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.4.8
|
127
117
|
signing_key:
|
128
118
|
specification_version: 4
|
129
119
|
summary: Summary of OpenteamCommons.
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module OpenteamCommons
|
2
|
-
module Generators
|
3
|
-
class InstallGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
def create_binaries
|
7
|
-
copy_file 'script/start_site'
|
8
|
-
copy_file 'script/update_site'
|
9
|
-
|
10
|
-
chmod 'script/start_site', 0755
|
11
|
-
chmod 'script/update_site', 0755
|
12
|
-
end
|
13
|
-
|
14
|
-
def create_libs
|
15
|
-
directory 'lib'
|
16
|
-
end
|
17
|
-
|
18
|
-
def create_configs
|
19
|
-
directory 'config'
|
20
|
-
copy_file 'Procfile'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
|
@@ -1,39 +0,0 @@
|
|
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_dir
|
19
|
-
@log_dir ||= FileUtils.mkdir_p("/var/log/#{group}/#{project}").first rescue "#{root}/log"
|
20
|
-
end
|
21
|
-
|
22
|
-
def log(file=nil)
|
23
|
-
"#{log_dir}/#{file}"
|
24
|
-
end
|
25
|
-
|
26
|
-
def pid_file
|
27
|
-
@pid_file ||= begin
|
28
|
-
FileUtils.mkdir_p("/var/run/#{group}")
|
29
|
-
"/var/run/#{group}/#{project}.pid"
|
30
|
-
rescue Errno::EACCES
|
31
|
-
"/tmp/#{group}-#{project}.pid"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def heroku?
|
36
|
-
ENV['PORT']
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require File.expand_path('../directories.rb', __FILE__)
|
2
|
-
|
3
|
-
dir = Directories.new
|
4
|
-
|
5
|
-
if RUBY_PLATFORM =~ /freebsd/
|
6
|
-
set :job_template, "/usr/local/bin/bash -l -i -c ':job' 1>#{dir.log('schedule.log')} 2>#{dir.log('schedule-errors.log')}"
|
7
|
-
else
|
8
|
-
set :job_template, "/bin/bash -l -i -c ':job' 1>#{dir.log('schedule.log')} 2>#{dir.log('schedule-errors.log')}"
|
9
|
-
end
|
10
|
-
|
11
|
-
every :day do
|
12
|
-
rake 'cron'
|
13
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
app:
|
2
|
-
secret: SECRET
|
3
|
-
|
4
|
-
errors:
|
5
|
-
key: KEY
|
6
|
-
url: http://errors.openteam.ru
|
7
|
-
|
8
|
-
#solr:
|
9
|
-
# url: http://localhost:8982/solr
|
10
|
-
|
11
|
-
#sso:
|
12
|
-
# key: KEY
|
13
|
-
# secret: SECRET
|
14
|
-
# url: http://esp-sso.openteam.ru
|
15
|
-
|
16
|
-
#storage
|
17
|
-
#url: http://esp-storage.openteam.ru
|
18
|
-
|
19
|
-
unicorn:
|
20
|
-
workers: 2
|
21
|
-
timeout: 300
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.expand_path('../directories.rb', __FILE__)
|
2
|
-
|
3
|
-
dir = Directories.new
|
4
|
-
|
5
|
-
def dir.settings
|
6
|
-
heroku? ? {} : (YAML.load_file(config('settings.yml'))['unicorn'] || {})
|
7
|
-
end
|
8
|
-
def dir.old_pid
|
9
|
-
"#{pid_file}.oldbin"
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
worker_processes (dir.settings['workers'] || ENV['UNICORN_WORKERS'] || 2).to_i
|
14
|
-
timeout (dir.settings['timeout'] || ENV['UNICORN_TIMEOUT'] || 300).to_i
|
15
|
-
preload_app true
|
16
|
-
pid dir.pid_file
|
17
|
-
|
18
|
-
listen ENV['PORT'].to_i, :tcp_nopush => false if ENV['PORT'].to_i > 0
|
19
|
-
|
20
|
-
unless dir.heroku?
|
21
|
-
listen "/tmp/#{dir.group}-#{dir.project}.sock", :backlog => 64
|
22
|
-
|
23
|
-
stdout_path dir.log('stdout.log')
|
24
|
-
stderr_path dir.log('stderr.log')
|
25
|
-
end
|
26
|
-
|
27
|
-
before_fork do |server, worker|
|
28
|
-
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
29
|
-
|
30
|
-
if File.exists?(dir.old_pid) && server.pid != dir.old_pid
|
31
|
-
begin
|
32
|
-
Process.kill("QUIT", File.read(dir.old_pid).to_i)
|
33
|
-
rescue Errno::ENOENT, Errno::ESRCH
|
34
|
-
# someone else did our job for us
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
after_fork do |server, worker|
|
40
|
-
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
|
41
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
load_rvm_rc() {
|
4
|
-
if [ -f ~/.rvm/scripts/rvm ]; then
|
5
|
-
source ~/.rvm/scripts/rvm
|
6
|
-
fi
|
7
|
-
|
8
|
-
RVMRC_DIR=${CURRENT_PATH}
|
9
|
-
for ((;;)); do
|
10
|
-
if [ -f ${RVMRC_DIR}/.rvmrc ]; then
|
11
|
-
. ${RVMRC_DIR}/.rvmrc
|
12
|
-
break
|
13
|
-
elif [ "${RVMRC_DIR}" == "/" ]; then
|
14
|
-
break
|
15
|
-
fi
|
16
|
-
RVMRC_DIR=$(dirname ${RVMRC_DIR})
|
17
|
-
done
|
18
|
-
}
|
19
|
-
|
20
|
-
exec_git() {
|
21
|
-
/usr/bin/env git --git-dir=${CURRENT_PATH}/.git --work-tree=${CURRENT_PATH} $@
|
22
|
-
}
|
23
|
-
|
24
|
-
exec_rake() {
|
25
|
-
RAILS_ENV=production ${CURRENT_PATH}/bin/rake -f ${CURRENT_PATH}/Rakefile $@
|
26
|
-
}
|
27
|
-
|
28
|
-
exec_bundle() {
|
29
|
-
BUNDLE_GEMFILE=${CURRENT_PATH}/Gemfile bundle $@
|
30
|
-
}
|
31
|
-
|
32
|
-
reload_rc_script() {
|
33
|
-
if [ $(/usr/bin/uname) == "FreeBSD" ]; then
|
34
|
-
RC_PATH=/usr/local/etc/rc.d/
|
35
|
-
RC_SCRIPT=${RC_PATH}/${PROJECT_GROUP}-${PROJECT_NAME}.sh
|
36
|
-
RC_SUBSCRIBER_SCRIPT=${RC_PATH}/${PROJECT_GROUP}-${PROJECT_NAME}-subscriber.sh
|
37
|
-
else
|
38
|
-
RC_PATH=/etc/init.d/
|
39
|
-
RC_SCRIPT=${RC_PATH}/${PROJECT_GROUP}-${PROJECT_NAME}
|
40
|
-
RC_SUBSCRIBER_SCRIPT=${RC_PATH}/${PROJECT_GROUP}-${PROJECT_NAME}-subscriber
|
41
|
-
fi
|
42
|
-
|
43
|
-
if [ -f ${RC_SCRIPT} ]; then
|
44
|
-
${RC_SCRIPT} reload
|
45
|
-
fi
|
46
|
-
if [ -f ${RC_SUBSCRIBER_SCRIPT} ]; then
|
47
|
-
${RC_SUBSCRIBER_SCRIPT} restart
|
48
|
-
fi
|
49
|
-
}
|
50
|
-
|
51
|
-
bundle_update() {
|
52
|
-
exec_bundle --path .bundle --binstubs --clean --without test:development
|
53
|
-
}
|
54
|
-
|
55
|
-
CURRENT_PATH=$(dirname $(dirname $(realpath $0)))
|
56
|
-
|
57
|
-
PROJECT_GROUP=$(basename $(dirname ${CURRENT_PATH}))
|
58
|
-
PROJECT_NAME=$(basename ${CURRENT_PATH})
|
59
|
-
|
60
|
-
if [ $(/usr/bin/uname) == "FreeBSD" ]; then
|
61
|
-
exec_git checkout Gemfile.lock
|
62
|
-
fi
|
63
|
-
|
64
|
-
exec_git fetch
|
65
|
-
exec_git merge origin/master
|
66
|
-
|
67
|
-
load_rvm_rc
|
68
|
-
|
69
|
-
bundle_update
|
70
|
-
|
71
|
-
if [ -f "${CURRENT_PATH}/config/database.yml" ]; then
|
72
|
-
exec_rake db:migrate
|
73
|
-
fi
|
74
|
-
|
75
|
-
if [ "x${1}" == "x--assets" ]; then
|
76
|
-
exec_rake assets:precompile:primary assets:precompile:nondigest
|
77
|
-
fi
|
78
|
-
|
79
|
-
reload_rc_script
|
80
|
-
|
81
|
-
if [ -f "${CURRENT_PATH}/lib/tasks/cron.rake" ]; then
|
82
|
-
exec_bundle exec whenever --update-crontab --load-file "${CURRENT_PATH}/config/schedule.rb"
|
83
|
-
fi
|
84
|
-
|
85
|
-
exec_rake airbrake:deploy TO=production
|