adminix 0.1.49 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/adminix.gemspec +1 -4
- data/app/assets/images/logo.png +0 -0
- data/app/assets/javascripts/application.js +50 -0
- data/app/assets/javascripts/bootstrap.min.js +7 -0
- data/app/assets/javascripts/dataTables.bootstrap4.js +184 -0
- data/app/assets/javascripts/jquery.dataTables.js +15243 -0
- data/app/assets/javascripts/jquery.min.js +2 -0
- data/app/assets/javascripts/sb-admin-2.min.js +6 -0
- data/app/assets/stylesheets/bootstrap.min.css +6 -0
- data/app/assets/stylesheets/dataTables.bootstrap.css +314 -0
- data/app/assets/stylesheets/dataTables.responsive.css +106 -0
- data/app/assets/stylesheets/font-awesome.min.css +4 -0
- data/app/assets/stylesheets/sb-admin-2.min.css +5 -0
- data/app/views/scripts/restart_watcher.sh.erb +9 -0
- data/app/views/scripts/run_script.sh.erb +12 -0
- data/app/views/scripts/start_process.sh.erb +7 -0
- data/app/views/scripts/stop_process.sh.erb +7 -0
- data/app/views/scripts/update_process.sh.erb +24 -0
- data/app/views/scripts/update_watcher.sh.erb +3 -0
- data/app/views/web/dashboard.html.erb +90 -0
- data/app/views/web/job.html.erb +46 -0
- data/app/views/web/link.html.erb +12 -0
- data/app/views/web/loadstamp.html.erb +57 -0
- data/app/views/web/log.html.erb +49 -0
- data/app/views/web/partials/footer.html.erb +11 -0
- data/app/views/web/partials/header.html.erb +50 -0
- data/bin/install_adminix +40 -0
- data/bin/push +13 -0
- data/development.log +0 -0
- data/exe/adminix +91 -28
- data/lib/adminix.rb +42 -5
- data/lib/adminix/config.rb +170 -96
- data/lib/adminix/entities.rb +5 -0
- data/lib/adminix/entities/job.rb +54 -0
- data/lib/adminix/entities/log.rb +21 -0
- data/lib/adminix/entities/service.rb +211 -0
- data/lib/adminix/entities/sysload_stamp.rb +37 -0
- data/lib/adminix/entities/variable.rb +32 -0
- data/lib/adminix/helpers.rb +7 -2
- data/lib/adminix/helpers/command.rb +73 -0
- data/lib/adminix/helpers/files.rb +82 -0
- data/lib/adminix/helpers/log_reader.rb +16 -0
- data/lib/adminix/helpers/net_http.rb +63 -0
- data/lib/adminix/helpers/output.rb +28 -0
- data/lib/adminix/helpers/systemctl.rb +54 -0
- data/lib/adminix/services.rb +3 -0
- data/lib/adminix/services/app_service.rb +143 -0
- data/lib/adminix/services/logs_service.rb +13 -0
- data/lib/adminix/services/system_load_service.rb +16 -0
- data/lib/adminix/version.rb +1 -1
- data/lib/adminix/watcher.rb +76 -144
- data/lib/adminix/web.rb +4 -0
- data/lib/adminix/web/router.rb +98 -0
- data/lib/adminix/web/server.rb +60 -0
- data/lib/adminix/web/view_helper.rb +14 -0
- data/lib/event_machine.rb +2 -0
- data/lib/event_machine/http_server.rb +2 -0
- data/lib/event_machine/http_server/response.rb +314 -0
- data/lib/event_machine/http_server/server.rb +107 -0
- data/lib/event_machine/tail.rb +2 -0
- data/lib/event_machine/tail/filetail.rb +470 -0
- data/lib/event_machine/tail/globwatcher.rb +294 -0
- metadata +60 -45
- data/lib/adminix/errors.rb +0 -7
- data/lib/adminix/helpers/file.rb +0 -13
- data/lib/adminix/helpers/http.rb +0 -19
- data/lib/adminix/log_watch_handler.rb +0 -23
- data/lib/adminix/server_setup.rb +0 -76
- data/lib/adminix/service.rb +0 -179
- data/lib/adminix/setup.rb +0 -3
- data/lib/adminix/setup/routes.rb +0 -113
- data/lib/adminix/setup/services.rb +0 -139
- data/lib/adminix/setup/views.rb +0 -183
- data/lib/adminix/system.rb +0 -106
- data/views/daemon_scripts/upstart.conf.erb +0 -23
data/lib/adminix/setup/views.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
module Adminix::Setup
|
2
|
-
module Views
|
3
|
-
def self.root_view(_assigns)
|
4
|
-
layout do
|
5
|
-
%{
|
6
|
-
<div class="row">
|
7
|
-
<div class="col-md-6 col-md-offset-3">
|
8
|
-
<br/>
|
9
|
-
<a href="http://adminix.io" title="Adminix website" target="_blank">
|
10
|
-
<img src="http://www.adminix.io/images/logo_square.jpg" alt="Adminix logo" class="img-responsive center-block" style="width: 130px" />
|
11
|
-
</a>
|
12
|
-
<br/>
|
13
|
-
<p>Thank you for using Adminix image!</p>
|
14
|
-
<p>Your application is almost deployed, please click on "Continue" button to finish setup process.</p>
|
15
|
-
<button type="button" class="btn btn-primary" onclick="location.href='/sign-up';">Continue</button>
|
16
|
-
<br/><br/>
|
17
|
-
<a href="http://adminix.io" title="Adminix website" target="_blank">Click to visit our website</a>
|
18
|
-
</div>
|
19
|
-
</div>
|
20
|
-
}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.login_view(assigns)
|
25
|
-
session = assigns[:session] || {}
|
26
|
-
errors = assigns[:errors] || []
|
27
|
-
layout do
|
28
|
-
panel(title: 'Login') do
|
29
|
-
%{
|
30
|
-
<form method="POST" action="/login">
|
31
|
-
#{form_group('email', type: 'email', name: 'session[email]', label: 'Email', placeholder: 'Please enter your email', value: session[:email])}
|
32
|
-
#{form_group('password', type: 'password', name: 'session[password]', label: 'Password', placeholder: 'Please enter your password')}
|
33
|
-
#{errors.count != 0 ? render_errors(errors) : ''}
|
34
|
-
<button type="submit" class="btn btn-primary">Login</button>
|
35
|
-
<br/><br/>
|
36
|
-
<a href="/sign-up" title="Sign up">New to Adminix? Create a FREE account</a>
|
37
|
-
</form>
|
38
|
-
}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.sign_up_view(assigns)
|
44
|
-
user = assigns[:user] || {}
|
45
|
-
errors = assigns[:errors] || []
|
46
|
-
layout do
|
47
|
-
panel(title: 'Create a FREE Adminix account') do
|
48
|
-
%{
|
49
|
-
<form method="POST" action="/sign-up">
|
50
|
-
#{form_group('first_name', type: 'text', name: 'user[first_name]', label: 'First name', placeholder: 'Please enter your first name', value: user[:first_name])}
|
51
|
-
#{form_group('last_name', type: 'text', name: 'user[last_name]', label: 'Last name', placeholder: 'Please enter your last name', value: user[:last_name])}
|
52
|
-
#{form_group('email', type: 'email', name: 'user[email]', label: 'Email', placeholder: 'Please enter your email', value: user[:email])}
|
53
|
-
#{form_group('password', type: 'password', name: 'user[password]', label: 'Password', placeholder: 'Please enter your password')}
|
54
|
-
#{errors.count != 0 ? render_errors(errors) : ''}
|
55
|
-
<button type="submit" class="btn btn-primary">Sign up</button>
|
56
|
-
<br/><br/>
|
57
|
-
<a href="/login" title="Login">Already have an account? Login</a>
|
58
|
-
</form>
|
59
|
-
}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.create_service_view(assigns)
|
65
|
-
layout do
|
66
|
-
panel(title: 'Create service') do
|
67
|
-
%{
|
68
|
-
<form method="POST" action="/create-service?t=#{assigns[:token]}">
|
69
|
-
#{form_group('name', type: 'text', name: 'service[name]', label: 'Service name', placeholder: 'Please enter your service name')}
|
70
|
-
<button type="submit" class="btn btn-primary" onclick="location.href='/complete';">Launch your service</button>
|
71
|
-
<br/><br/>
|
72
|
-
#{assigns[:service_exists] ? "<a href=\"/connect-service?t=#{assigns[:token]}\" title=\"Connect service\">Already have an existing service? Choose it</a>" : ''}
|
73
|
-
</form>
|
74
|
-
}
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.connect_service_view(assigns)
|
80
|
-
layout do
|
81
|
-
panel(title: 'Connect existing service') do
|
82
|
-
%{
|
83
|
-
<form method="POST" action="/connect-service?t=#{assigns[:token]}">
|
84
|
-
<div class="form-group">
|
85
|
-
<label for="service_id">Please select service to connect</label>
|
86
|
-
<select class="form-control" name="service[id]" id="service_id">
|
87
|
-
#{(assigns[:services].map { |s| "<option value='#{s['id']}'>#{s['name']}</option>" }).join('')}
|
88
|
-
</select>
|
89
|
-
</div>
|
90
|
-
<button type="submit" class="btn btn-primary">Launch your service</button>
|
91
|
-
<br/><br/>
|
92
|
-
<a href="/create-service?t=#{assigns[:token]}" title="Connect service">Want to create a new one? Create service</a>
|
93
|
-
</form>
|
94
|
-
}
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.complete_view(_assigns)
|
100
|
-
layout do
|
101
|
-
panel(title: 'Application setup process completed') do
|
102
|
-
%{
|
103
|
-
<p>Your application setup is completed.
|
104
|
-
}
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def self.error_view(_assigns)
|
110
|
-
layout do
|
111
|
-
panel(title: 'Something went wrong') do
|
112
|
-
%{
|
113
|
-
<p>Something went wrong please retry a process.</p>
|
114
|
-
}
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
private
|
120
|
-
|
121
|
-
def self.layout
|
122
|
-
%{
|
123
|
-
<html>
|
124
|
-
<head>
|
125
|
-
<title>Adminix setup</title>
|
126
|
-
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
127
|
-
</head>
|
128
|
-
<body>
|
129
|
-
<div class="container">
|
130
|
-
#{yield}
|
131
|
-
</div>
|
132
|
-
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
133
|
-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
134
|
-
</body>
|
135
|
-
</html>
|
136
|
-
}
|
137
|
-
end
|
138
|
-
|
139
|
-
def self.panel(assigns)
|
140
|
-
%{
|
141
|
-
<div class="row">
|
142
|
-
<div class="col-md-offset-2 col-md-8">
|
143
|
-
<div class="panel panel-default">
|
144
|
-
<div class="panel-heading clearfix">
|
145
|
-
<i class="icon-calendar"></i>
|
146
|
-
<h3 class="panel-title">#{assigns[:title]}</h3>
|
147
|
-
</div>
|
148
|
-
<div class="panel-body">
|
149
|
-
<div class="row">
|
150
|
-
<div class="col-md-6 col-md-offset-3">
|
151
|
-
#{yield}
|
152
|
-
</div>
|
153
|
-
</div>
|
154
|
-
</div>
|
155
|
-
</div>
|
156
|
-
</div>
|
157
|
-
}
|
158
|
-
end
|
159
|
-
|
160
|
-
def self.render_errors(errors)
|
161
|
-
flash (errors.map { |k,v| "#{v}<br/>" }).join('<br/>')
|
162
|
-
text = errors.map do |attr, errors|
|
163
|
-
(errors.map { |err| "#{attr} #{err}" }).join('<br/>')
|
164
|
-
end.join('<br/>')
|
165
|
-
|
166
|
-
flash(text)
|
167
|
-
end
|
168
|
-
|
169
|
-
def self.flash(text, type='danger')
|
170
|
-
%{<div class="alert alert-#{type}">#{text}</div>}
|
171
|
-
end
|
172
|
-
|
173
|
-
def self.form_group(id, assigns)
|
174
|
-
%{
|
175
|
-
<div class="form-group">
|
176
|
-
<label for="#{id}">#{assigns[:label]}</label>
|
177
|
-
<input type="#{assigns[:type]}" name="#{assigns[:name]}" value="#{assigns[:value]}" class="form-control" id="#{id}" placeholder="#{assigns[:placeholder]}">
|
178
|
-
</div>
|
179
|
-
}
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
data/lib/adminix/system.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'erb'
|
3
|
-
|
4
|
-
module Adminix
|
5
|
-
class System
|
6
|
-
include Singleton
|
7
|
-
|
8
|
-
def self.windows?
|
9
|
-
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.mac?
|
13
|
-
(/darwin/ =~ RUBY_PLATFORM) != nil
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.unix?
|
17
|
-
!self.windows?
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.linux?
|
21
|
-
self.unix? and not self.mac?
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.rvm?
|
25
|
-
true
|
26
|
-
end
|
27
|
-
|
28
|
-
attr_reader :os, :processor_load, :memory_load, :username, :home, :adminix_bin, :ruby_version
|
29
|
-
|
30
|
-
def initialize
|
31
|
-
define_os
|
32
|
-
parse_system_info
|
33
|
-
define_adminix_bin
|
34
|
-
check_system_load
|
35
|
-
end
|
36
|
-
|
37
|
-
def generate_daemon
|
38
|
-
template = File.read("#{Adminix::root}/views/daemon_scripts/upstart.conf.erb")
|
39
|
-
file_content = ERB.new(template).result(binding)
|
40
|
-
|
41
|
-
file_path = `pwd`.split("\n")[0] + '/adminix.conf'
|
42
|
-
File.delete(file_path) if File.exists?(file_path)
|
43
|
-
File.open(file_path, 'w') { |file| file.write(file_content) }
|
44
|
-
|
45
|
-
file_path
|
46
|
-
end
|
47
|
-
|
48
|
-
def eval(cmd)
|
49
|
-
`#{cmd}`
|
50
|
-
rescue => e
|
51
|
-
e.to_s
|
52
|
-
end
|
53
|
-
|
54
|
-
def sudo?
|
55
|
-
@username == 'root'
|
56
|
-
end
|
57
|
-
|
58
|
-
def check_system_load
|
59
|
-
case @os
|
60
|
-
when :mac
|
61
|
-
@processor_load = `ps -A -o %cpu | awk '{s+=$1} END {print s "%"}'`.to_f
|
62
|
-
@memory_load = 0.1
|
63
|
-
when :linux, :unix
|
64
|
-
@processor_load = `grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}'`.to_f
|
65
|
-
@memory_load = `free | grep Mem | awk '{print $3/$2 * 100.0}'`.to_f
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def log(message)
|
70
|
-
puts message unless config.daemon
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def config
|
76
|
-
Config.instance
|
77
|
-
end
|
78
|
-
|
79
|
-
def define_os
|
80
|
-
@os = if self.class.windows?
|
81
|
-
:windows
|
82
|
-
elsif self.class.mac?
|
83
|
-
:mac
|
84
|
-
elsif self.class.unix?
|
85
|
-
:unix
|
86
|
-
elsif self.class.linux?
|
87
|
-
:linux
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def parse_system_info
|
92
|
-
@username = ENV['USER'] || `whoami`.split("\n")[0]
|
93
|
-
@home = "/home/#{@username}"
|
94
|
-
@ruby_version = RUBY_VERSION
|
95
|
-
end
|
96
|
-
|
97
|
-
def define_adminix_bin
|
98
|
-
@adminix_bin = if self.class.rvm?
|
99
|
-
"/home/#{@username}/.rvm/gems/ruby-#{@ruby_version}/wrappers/adminix"
|
100
|
-
else
|
101
|
-
"/usr/local/bin/adminix"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
description "Ruby example upstart conf"
|
2
|
-
|
3
|
-
setuid <%= @username %>
|
4
|
-
setgid <%= @username %>
|
5
|
-
|
6
|
-
<%#start on runlevel [2345]%>
|
7
|
-
<%#stop on runlevel [06]%>
|
8
|
-
|
9
|
-
respawn
|
10
|
-
respawn limit 3 30
|
11
|
-
|
12
|
-
# env RAILS_ENV=production
|
13
|
-
|
14
|
-
# pre-start script
|
15
|
-
# use this for any pre-start stuff
|
16
|
-
# end script
|
17
|
-
|
18
|
-
script
|
19
|
-
exec /bin/bash <<EOS
|
20
|
-
export HOME=<%= @home %>
|
21
|
-
exec <%= @adminix_bin %> watch
|
22
|
-
EOS
|
23
|
-
end script
|