adminix 0.1.27 → 0.1.29

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: 45e38f6ab291533bc9d2ddfea1b40d395a9c2a38
4
- data.tar.gz: d9aab6442d891b7941e79425a0176e2c92c1379b
3
+ metadata.gz: 650f37981b425876a29f92836c4bd6a77e95ccc6
4
+ data.tar.gz: bef0c035fcd673ac2d8e81966fbbec7d3d88d47f
5
5
  SHA512:
6
- metadata.gz: fc6c55db0afc0caa75a98445f753bcd2dd8c4b9d595002be195881144e7500e0b0740f72620da36841e460ea229ea6ac3db25c6164c648fc4d37c250358b0ca8
7
- data.tar.gz: a319109ccdb06cec1340738c53ba5b5e6031ff2ad840073ab2142dab97be9abe037f91f561e8278cf77da6783f661685675e8f6030a0da02f40cb03a7a4073e4
6
+ metadata.gz: 70fe0ca6aa0d996b306a464321ec61e25000b90a43199e5998dbf35e16d9cae48afa3850e958315127365254f38a2489c0c1f1e5f35cff08546777635d3f7e44
7
+ data.tar.gz: 52bc0612a38dd38ebdaf1d71158dd6034f19caafb6aee2900146e3efff549753b133756627d29fabf4fd46becbe451fb1c39029f0fabc4c3520c19c8509995b6
data/adminix.gemspec CHANGED
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency "eventmachine", "1.2.3"
34
- spec.add_dependency "action_cable_client", "2.0.0"
33
+ spec.add_dependency "eventmachine", "1.2.5"
34
+ spec.add_dependency "action_cable_client", "2.0.2"
35
35
  spec.add_dependency "sinatra", "1.4.8"
36
36
 
37
37
  spec.add_development_dependency "bundler", "~> 1.14"
data/exe/adminix CHANGED
@@ -49,6 +49,7 @@ unless options[:action] == "help"
49
49
  config.service_id = options[:service_id]
50
50
  config.daemon = options[:daemonize]
51
51
  config.read_local_config
52
+ config.sync_remote_config
52
53
  end
53
54
 
54
55
  case options[:action]
@@ -8,15 +8,19 @@ module Adminix
8
8
  DEFAULT_HOST = 'https://api.adminix.io'.freeze
9
9
  DEFAULT_WEBSOCKET_HOST = 'wss://api.adminix.io/websocket'.freeze
10
10
  DEFAULT_SETUP_SERVER_PORT = '8080'
11
+ DEFAULT_WATCHER_SYNC_PERIOD = 10.freeze
12
+ DEFAULT_LOGS_SYNC_PERIOD = 3.freeze
13
+ DEFAULT_LOGS_ENABLED = true
11
14
 
12
- attr_accessor :service_id, :secret_key, :host, :commands, :daemon, :setup_server_port, :scripts, :watch_log_files, :watcher_sync_period, :logs_sync_period, :websocket_path, :mode, :working_dir
15
+ attr_accessor :service_id, :secret_key, :host, :commands, :daemon, :setup_server_port, :scripts, :watch_log_files, :watcher_sync_period, :logs_sync_period, :logs_enabled, :websocket_path, :mode, :working_dir
13
16
 
14
17
  def initialize
15
18
  @host = ENV['ADMINIX_HOST'] || DEFAULT_HOST
16
19
  @setup_server_port = ENV['ADMINIX_SETUP_SERVER_PORT'] || DEFAULT_SETUP_SERVER_PORT
17
20
  @commands = []
18
- @watcher_sync_period = 10
19
- @logs_sync_period = 3
21
+ @watcher_sync_period = DEFAULT_WATCHER_SYNC_PERIOD
22
+ @logs_sync_period = DEFAULT_LOGS_SYNC_PERIOD
23
+ @logs_enabled = DEFAULT_LOGS_ENABLED
20
24
  @websocket_path = ENV['ADMINIX_WEBSOCKET_HOST'] || DEFAULT_WEBSOCKET_HOST
21
25
  @mode = 'classic'
22
26
  @working_dir = `pwd`.split("\n").first
@@ -63,6 +67,24 @@ module Adminix
63
67
  end
64
68
  end
65
69
 
70
+ def sync_remote_config
71
+ uri = URI.parse("#{@host}/v1/services/#{@service_id}/watcher_config")
72
+ request = Net::HTTP::Get.new(uri)
73
+ request["Authorization"] = "Bearer #{@secret_key}"
74
+
75
+ opts = { use_ssl: uri.scheme == 'https' }
76
+ response = Net::HTTP.start(uri.hostname, uri.port, opts) do |http|
77
+ http.request(request)
78
+ end
79
+
80
+ data = JSON.parse(response.body)
81
+ result = data['result'] || {}
82
+
83
+ @watcher_sync_period = result['sync_period'] || DEFAULT_WATCHER_SYNC_PERIOD
84
+ @logs_sync_period = result['logs_sync_period'] || DEFAULT_LOGS_SYNC_PERIOD
85
+ @logs_enables = result.key?('logs_enabled') ? result['logs_enabled'] == true : DEFAULT_LOGS_ENABLED
86
+ end
87
+
66
88
  def export_credentials
67
89
  create_config_root_if_not_exists
68
90
 
@@ -36,7 +36,7 @@ module Adminix
36
36
  commands_queue.each do |q|
37
37
  if q['status'] != 'processed'
38
38
  res = execute_command(q['command_key'], q['process_id'], q['args'] || {})
39
- ws_client.perform(:task_completed, res)
39
+ ws_client.perform(:task_completed, res) if ws_client.subscribed?
40
40
  end
41
41
  end
42
42
  end
@@ -1,3 +1,3 @@
1
1
  module Adminix
2
- VERSION = "0.1.27"
2
+ VERSION = "0.1.29"
3
3
  end
@@ -76,10 +76,12 @@ module Adminix
76
76
  end
77
77
 
78
78
  # Logs watcher
79
- config.watch_log_files.each do |file_path|
80
- File.write(file_path, '') unless File.exists?(file_path)
81
- if File.exists?(file_path)
82
- EventMachine.watch_file(file_path, Adminix::LogWatchHandler)
79
+ if config.logs_enabled
80
+ config.watch_log_files.each do |file_path|
81
+ File.write(file_path, '') unless File.exists?(file_path)
82
+ if File.exists?(file_path)
83
+ EventMachine.watch_file(file_path, Adminix::LogWatchHandler)
84
+ end
83
85
  end
84
86
  end
85
87
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adminix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.27
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Dyl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-14 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.3
19
+ version: 1.2.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.3
26
+ version: 1.2.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: action_cable_client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0
33
+ version: 2.0.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.0
40
+ version: 2.0.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sinatra
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  requirements: []
189
189
  rubyforge_project:
190
- rubygems_version: 2.6.11
190
+ rubygems_version: 2.6.13
191
191
  signing_key:
192
192
  specification_version: 4
193
193
  summary: Adminix