adminix 0.1.47 → 0.1.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/build +12 -0
- data/exe/adminix +10 -2
- data/lib/adminix/helpers/file.rb +13 -0
- data/lib/adminix/helpers/http.rb +19 -0
- data/lib/adminix/helpers.rb +2 -0
- data/lib/adminix/service.rb +31 -19
- data/lib/adminix/setup.rb +3 -3
- data/lib/adminix/version.rb +1 -1
- data/lib/adminix/watcher.rb +4 -5
- data/lib/adminix.rb +7 -6
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f33fd698ed6fad1f65f8c2db5194d63d4d6e89c67fa3fa1825e8972e5675eb3
|
4
|
+
data.tar.gz: 91bf7ff798147fe961ceaac7e66904c86de908a0ae4dea42f07d6b38dfc2c8dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b08d3d0e13c2a1df24fb129f6ec8ba4561933475191afb8e1bed990a337f29fbde22c2b42d06d59df19f803e809e17a1bbc17ac07f3503e2824f876787dd66f
|
7
|
+
data.tar.gz: e26ae4ea490b1faf3809f592e1930325502f852f20ea225ae29aa333cf8ec8871c3ecad4f67b4d79bfbc509197d11276c1f50bc7950485bb5a047a2b9f68f449
|
data/bin/build
ADDED
data/exe/adminix
CHANGED
@@ -20,6 +20,12 @@ parsers[:env] = OptionParser.new do |opts|
|
|
20
20
|
opts.separator ""
|
21
21
|
end
|
22
22
|
|
23
|
+
parsers[:download_source] = OptionParser.new do |opts|
|
24
|
+
opts.banner = "Downloads a project source if exists"
|
25
|
+
opts.separator " Usage: adminix download_source"
|
26
|
+
opts.separator ""
|
27
|
+
end
|
28
|
+
|
23
29
|
parsers[:watch] = OptionParser.new do |opts|
|
24
30
|
opts.banner = "Launch Adminix watcher"
|
25
31
|
opts.separator " Usage: adminix watch"
|
@@ -42,7 +48,7 @@ options[:action] = ARGV[0] || "help"
|
|
42
48
|
parsers[options[:action].to_sym].parse!(ARGV) rescue nil
|
43
49
|
|
44
50
|
unless options[:action] == "help"
|
45
|
-
|
51
|
+
require_relative '../lib/adminix'
|
46
52
|
config = Adminix::Config.instance
|
47
53
|
|
48
54
|
config.secret_key = options[:secret_key]
|
@@ -55,12 +61,14 @@ end
|
|
55
61
|
case options[:action]
|
56
62
|
when "env"
|
57
63
|
puts Adminix::Service.instance.options_to_envs
|
64
|
+
when "download_source"
|
65
|
+
puts Adminix::Service.instance.download_source
|
58
66
|
when "watch"
|
59
67
|
if config.credentials_defined?
|
60
68
|
puts Adminix::Watcher.run!(options)
|
61
69
|
else
|
62
70
|
puts 'Credentials are not defined, running setup server'
|
63
|
-
|
71
|
+
require_relative '../lib/adminix/server_setup'
|
64
72
|
end
|
65
73
|
when "version"
|
66
74
|
puts "adminix version #{Adminix::VERSION}"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Adminix
|
2
|
+
module Helpers
|
3
|
+
module HTTP
|
4
|
+
def self.get(path)
|
5
|
+
config = Adminix::Config.instance
|
6
|
+
uri = URI.parse("#{config.host}/v1/#{path}")
|
7
|
+
request = Net::HTTP::Get.new(uri)
|
8
|
+
request['Authorization'] = "Bearer #{config.secret_key}"
|
9
|
+
|
10
|
+
opts = { use_ssl: uri.scheme == 'https' }
|
11
|
+
response = Net::HTTP.start(uri.hostname, uri.port, opts) do |http|
|
12
|
+
http.request(request)
|
13
|
+
end
|
14
|
+
|
15
|
+
JSON.parse(response.body)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/adminix/service.rb
CHANGED
@@ -88,16 +88,7 @@ module Adminix
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def fetch_options
|
91
|
-
|
92
|
-
request = Net::HTTP::Get.new(uri)
|
93
|
-
request["Authorization"] = "Bearer #{config.secret_key}"
|
94
|
-
|
95
|
-
opts = { use_ssl: uri.scheme == 'https' }
|
96
|
-
response = Net::HTTP.start(uri.hostname, uri.port, opts) do |http|
|
97
|
-
http.request(request)
|
98
|
-
end
|
99
|
-
|
100
|
-
JSON.parse(response.body)
|
91
|
+
Helpers::HTTP.get("services/#{id}/options")
|
101
92
|
end
|
102
93
|
|
103
94
|
def count_logs_lines
|
@@ -111,7 +102,7 @@ module Adminix
|
|
111
102
|
end
|
112
103
|
|
113
104
|
def stop!
|
114
|
-
system.log
|
105
|
+
system.log 'Stopping process'
|
115
106
|
case config.mode
|
116
107
|
when 'classic'
|
117
108
|
system.eval("#{config.scripts[:process_stop]} && #{config.scripts[:process_start]}")
|
@@ -120,6 +111,27 @@ module Adminix
|
|
120
111
|
end
|
121
112
|
end
|
122
113
|
|
114
|
+
def download_source
|
115
|
+
data = fetch_options
|
116
|
+
unless data['success']
|
117
|
+
puts 'Error, please try again later!'
|
118
|
+
return
|
119
|
+
end
|
120
|
+
|
121
|
+
vars = data['result'] || []
|
122
|
+
bin = 'git'
|
123
|
+
repo_var = vars.find { |v| v['key'] == 'git_repo' }
|
124
|
+
branch_var = vars.find { |v| v['key'] == 'git_branch' }
|
125
|
+
|
126
|
+
if repo_var && repo_var['value'] && branch_var
|
127
|
+
repo = repo_var['value']
|
128
|
+
branch = branch_var['value'] || 'master'
|
129
|
+
`#{bin} clone #{repo} -b #{branch}`
|
130
|
+
else
|
131
|
+
puts 'Please define your GIT repository and branch'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
123
135
|
private
|
124
136
|
|
125
137
|
def config
|
@@ -137,27 +149,27 @@ module Adminix
|
|
137
149
|
def execute_command(key, process_id, args)
|
138
150
|
command = config.commands.find { |c| c['key'] == key }
|
139
151
|
script = command['command'].dup
|
140
|
-
|
152
|
+
|
141
153
|
# TODO frontend fix attribute args
|
142
154
|
args.each { |hs| script.gsub!("%{#{hs[0]}}", hs[1]) }
|
143
155
|
|
144
156
|
# export_envs = options_to_envs_inline
|
145
157
|
# script = "cd #{config.working_dir} && #{export_envs} && #{script}"
|
146
158
|
|
147
|
-
system.log
|
148
|
-
system.log
|
159
|
+
system.log 'Executing command: '
|
160
|
+
system.log '-----------------------------------'
|
149
161
|
system.log script
|
150
|
-
system.log
|
162
|
+
system.log '-----------------------------------'
|
151
163
|
|
152
164
|
output = system.eval("#{config.scripts[:run_script]} #{script}")
|
153
165
|
|
154
|
-
system.log
|
155
|
-
system.log
|
166
|
+
system.log 'Command execution output: '
|
167
|
+
system.log '-----------------------------------'
|
156
168
|
system.log output
|
157
|
-
system.log
|
169
|
+
system.log '-----------------------------------'
|
158
170
|
|
159
171
|
{
|
160
|
-
id: process_id,
|
172
|
+
id: process_id,
|
161
173
|
success: true,
|
162
174
|
output: output
|
163
175
|
}
|
data/lib/adminix/setup.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# require_relative 'setup/views'
|
2
|
+
# require_relative 'setup/services'
|
3
|
+
# require_relative 'setup/routes'
|
data/lib/adminix/version.rb
CHANGED
data/lib/adminix/watcher.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require "fileutils"
|
1
|
+
require 'eventmachine'
|
2
|
+
require 'action_cable_client'
|
4
3
|
|
5
4
|
module Adminix
|
6
5
|
class Watcher
|
@@ -57,8 +56,8 @@ module Adminix
|
|
57
56
|
log_files_exists = false
|
58
57
|
config.watch_log_files.each do |file_path|
|
59
58
|
dirname = File.dirname(file_path)
|
60
|
-
|
61
|
-
|
59
|
+
Helpers::File.mkdir_p(dirname) unless File.directory?(dirname)
|
60
|
+
Helpers::File.touch(file_path) unless File.exists?(file_path)
|
62
61
|
|
63
62
|
if File.exists?(file_path)
|
64
63
|
log_files_exists = true
|
data/lib/adminix.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
require_relative 'adminix/version'
|
2
2
|
# require 'adminix/errors'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
require_relative 'adminix/helpers'
|
4
|
+
require_relative 'adminix/config'
|
5
|
+
require_relative 'adminix/service'
|
6
|
+
require_relative 'adminix/system'
|
7
|
+
require_relative 'adminix/log_watch_handler'
|
8
|
+
require_relative 'adminix/watcher'
|
8
9
|
|
9
10
|
module Adminix
|
10
11
|
def self.root
|
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.
|
4
|
+
version: 0.1.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Dyl
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -193,12 +193,16 @@ files:
|
|
193
193
|
- README.md
|
194
194
|
- Rakefile
|
195
195
|
- adminix.gemspec
|
196
|
+
- bin/build
|
196
197
|
- bin/console
|
197
198
|
- bin/setup
|
198
199
|
- exe/adminix
|
199
200
|
- lib/adminix.rb
|
200
201
|
- lib/adminix/config.rb
|
201
202
|
- lib/adminix/errors.rb
|
203
|
+
- lib/adminix/helpers.rb
|
204
|
+
- lib/adminix/helpers/file.rb
|
205
|
+
- lib/adminix/helpers/http.rb
|
202
206
|
- lib/adminix/log_watch_handler.rb
|
203
207
|
- lib/adminix/server_setup.rb
|
204
208
|
- lib/adminix/service.rb
|