adminix 0.1.26 → 0.1.27

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a37299c44d032386ade1950f6523bb6ded0e8365
4
- data.tar.gz: 76f9af22934ea38984b07c86153e7e903e95653a
3
+ metadata.gz: 45e38f6ab291533bc9d2ddfea1b40d395a9c2a38
4
+ data.tar.gz: d9aab6442d891b7941e79425a0176e2c92c1379b
5
5
  SHA512:
6
- metadata.gz: 852c9f5871d90734dc4789bd8c3d96a647650a9ca16721eed4cd5976ddf6899bb9a0b7b5cab14c551a5100888af40b8e5cb9879d8b1588d00b658f8b783faa99
7
- data.tar.gz: 6044c8ab1faab8b55ac4b98549103aaff6e0ea68565eb6f36b45cbac12d0ec350a81ef46e676e0af94131604f968667c9114823f74ee89c77ea8a7d2c0b8e223
6
+ metadata.gz: fc6c55db0afc0caa75a98445f753bcd2dd8c4b9d595002be195881144e7500e0b0740f72620da36841e460ea229ea6ac3db25c6164c648fc4d37c250358b0ca8
7
+ data.tar.gz: a319109ccdb06cec1340738c53ba5b5e6031ff2ad840073ab2142dab97be9abe037f91f561e8278cf77da6783f661685675e8f6030a0da02f40cb03a7a4073e4
@@ -9,7 +9,7 @@ module Adminix
9
9
  DEFAULT_WEBSOCKET_HOST = 'wss://api.adminix.io/websocket'.freeze
10
10
  DEFAULT_SETUP_SERVER_PORT = '8080'
11
11
 
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
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
13
13
 
14
14
  def initialize
15
15
  @host = ENV['ADMINIX_HOST'] || DEFAULT_HOST
@@ -19,6 +19,7 @@ module Adminix
19
19
  @logs_sync_period = 3
20
20
  @websocket_path = ENV['ADMINIX_WEBSOCKET_HOST'] || DEFAULT_WEBSOCKET_HOST
21
21
  @mode = 'classic'
22
+ @working_dir = `pwd`.split("\n").first
22
23
  @scripts = {
23
24
  watcher_start: 'sudo systemctl start adminix.service',
24
25
  watcher_stop: 'sudo systemctl stop adminix.service',
@@ -48,6 +49,7 @@ module Adminix
48
49
  data = JSON.parse(content) rescue {}
49
50
 
50
51
  @mode = data['mode'] || 'classic'
52
+ @working_dir = data['working_dir'] if data['working_dir']
51
53
 
52
54
  scripts = data['scripts'] || {}
53
55
  @scripts = {
@@ -114,7 +114,7 @@ module Adminix
114
114
  system.log "Stopping process"
115
115
  case config.mode
116
116
  when 'classic'
117
- system.eval("#{config.scripts[:watcher_stop]} && #{config.scripts[:watcher_start]}")
117
+ system.eval("#{config.scripts[:process_stop]} && #{config.scripts[:process_start]}")
118
118
  when 'docker'
119
119
  Process.kill('INT', 1) rescue nil
120
120
  end
@@ -131,7 +131,7 @@ module Adminix
131
131
  end
132
132
 
133
133
  def file_lines_number(file_path)
134
- `wc -l #{file_path}`.to_i
134
+ File.exists?(file_path) ? `wc -l #{file_path}`.to_i : 0
135
135
  end
136
136
 
137
137
  def execute_command(key, process_id, args)
@@ -142,7 +142,7 @@ module Adminix
142
142
  args.each { |hs| script.gsub!("%{#{hs[0]}}", hs[1]) }
143
143
 
144
144
  export_envs = options_to_envs_inline
145
- script = "#{export_envs} && #{script}"
145
+ script = "cd #{config.working_dir} && #{export_envs} && #{script}"
146
146
 
147
147
  system.log "Executing command: "
148
148
  system.log "-----------------------------------"
@@ -1,3 +1,3 @@
1
1
  module Adminix
2
- VERSION = "0.1.26"
2
+ VERSION = "0.1.27"
3
3
  end
@@ -77,7 +77,10 @@ module Adminix
77
77
 
78
78
  # Logs watcher
79
79
  config.watch_log_files.each do |file_path|
80
- EventMachine.watch_file(file_path, Adminix::LogWatchHandler)
80
+ File.write(file_path, '') unless File.exists?(file_path)
81
+ if File.exists?(file_path)
82
+ EventMachine.watch_file(file_path, Adminix::LogWatchHandler)
83
+ end
81
84
  end
82
85
 
83
86
  EventMachine.add_periodic_timer(config.logs_sync_period) do
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.26
4
+ version: 0.1.27
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-13 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine