focus_common 0.0.2 → 0.0.3

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
- SHA1:
3
- metadata.gz: 515e0d24e0dbb77aeb8e11135e9b1a241c8eb57c
4
- data.tar.gz: 402482fa00cf2edc78e23146d4a287b4060195e3
2
+ SHA256:
3
+ metadata.gz: 0f68c50ff019b3943eb41032e45c47428bd5f8edf53f61cdc1d25164400039a4
4
+ data.tar.gz: 513d24a149fe4c742679a73ff0307bd062ec5f6929a60a0bb5216a94d5ffb133
5
5
  SHA512:
6
- metadata.gz: cd8d8d042421fa286fc97beffee421d43d830985963ff8ff8d83d69374cf6222d6e88d96561bf789b7b36078e564a82ebcf4348d4687ce9922968af76ae29fc7
7
- data.tar.gz: 660545e1ba7657395faf069ff9277641d08760e31ef677252a9f128edcb102cac91d84ac4eab78ccc5bec0e5709edf2f58adcc4811bf5f41103d6ded3cdbae4e
6
+ metadata.gz: 23a63d542e1226f80f6e92e4756ee8940df30c810715edef745a32b34afa3654a22dc73fb41363947fe977cf2180322864f890236a0cc5da874b7c558724bf4c
7
+ data.tar.gz: de52371e9a48df210c257fe75f6232ea1bbb4edaa94d5c74ed12537dbe586d8766648271acd312d01b1ed81284813c331fc40287322c6196835fafc2f4a857a2
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
File without changes
File without changes
@@ -0,0 +1,73 @@
1
+ class FocusCommon::AppInfo
2
+
3
+ def get_database_time_info
4
+ conn = ActiveRecord::Base.connection
5
+ if conn.class.name.demodulize == 'Mysql2Adapter'
6
+ {zone: conn.execute("SELECT @@global.time_zone, @@session.time_zone;").to_a.flatten,
7
+ time: conn.execute("select concat(now(), '');").to_a.flatten.first,
8
+ }
9
+ else
10
+ {}
11
+ end
12
+ end
13
+
14
+ def git_version
15
+ if Rails.env.development?
16
+ `git rev-parse HEAD`
17
+ else
18
+ filename = File.join(Rails.root, 'REVISION')
19
+ if File.exists?(filename)
20
+ File.read(filename).strip
21
+ else
22
+ nil
23
+ end
24
+ end
25
+ end
26
+
27
+ def get_info
28
+ db_time_info = self.get_database_time_info
29
+ info = \
30
+ {
31
+ environment: {
32
+ rails: Rails.env,
33
+ stage: ENV['STAGE'],
34
+ },
35
+ version: {
36
+ ruby: RUBY_VERSION,
37
+ rails: Rails::VERSION::STRING,
38
+ git: git_version,
39
+ },
40
+ time: {
41
+ system: {
42
+ time: Time.now.to_s,
43
+ zone: Time.now.zone,
44
+ },
45
+ rails: {
46
+ time: Time.zone.now,
47
+ zone: Time.zone.to_s,
48
+ },
49
+ database: {
50
+ time: db_time_info[:time],
51
+ global_zone: db_time_info[:zone].try(:first),
52
+ session_zone: db_time_info[:zone].try(:second),
53
+ },
54
+ },
55
+ important_gems: get_gems.map{|g| [g.name, g.version]}.to_h.slice('sidekiq'),
56
+ }
57
+
58
+ if defined?(CbaDB)
59
+ info[:cba_site] = \
60
+ CbaDB.enabled_sites.map do |site|
61
+ namespace = CbaDB.sites_info.fetch(site, {})[:db_name]
62
+ [site, namespace]
63
+ end.to_h
64
+ end
65
+
66
+ info
67
+ end
68
+
69
+ def get_gems
70
+ Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }
71
+ end
72
+
73
+ end
@@ -1,18 +1,20 @@
1
1
  namespace :systemd do
2
2
 
3
3
  [:start, :stop, :restart].each do |cmd|
4
- task "app_#{cmd}" do
4
+ task "rails_#{cmd}", :app do |t, args|
5
5
  on roles(:app), in: :sequence, wait: 5 do
6
6
  within release_path do
7
- execute "sudo systemctl #{cmd} rails_#{fetch(:application)}"
7
+ app_name = args[:app] || fetch(:application)
8
+ execute "sudo systemctl #{cmd} rails_#{app_name}"
8
9
  end
9
10
  end
10
11
  end
11
12
 
12
- task "sidekiq_#{cmd}" do
13
- on roles(:app), in: :sequence, wait: 5 do
13
+ task "sidekiq_#{cmd}", [:app] do
14
+ on roles(:app), in: :sequence, wait: 5 do |t, args|
14
15
  within release_path do
15
- execute "sudo systemctl #{cmd} sidekiq_#{fetch(:application)}"
16
+ app_name = args[:app] || fetch(:application)
17
+ execute "sudo systemctl #{cmd} sidekiq_#{app_name}"
16
18
  end
17
19
  end
18
20
  end
@@ -1,4 +1,4 @@
1
1
  module FocusCommon
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
4
4
 
data/makefile CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: focus_common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - linjunhalida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-29 00:00:00.000000000 Z
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Common library for Focus Solution Inc Rails projects
14
14
  email:
@@ -24,6 +24,7 @@ files:
24
24
  - Rakefile
25
25
  - focus_common.gemspec
26
26
  - lib/focus_common.rb
27
+ - lib/focus_common/app_info.rb
27
28
  - lib/focus_common/capistrano.rb
28
29
  - lib/focus_common/version.rb
29
30
  - makefile
@@ -46,8 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
47
  - !ruby/object:Gem::Version
47
48
  version: '0'
48
49
  requirements: []
49
- rubyforge_project:
50
- rubygems_version: 2.5.2
50
+ rubygems_version: 3.0.8
51
51
  signing_key:
52
52
  specification_version: 4
53
53
  summary: Common library for Focus Solution Inc Rails projects