mlserver 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mlserver +24 -2
- data/lib/MLserver/logger.rb +10 -4
- data/lib/MLserver/server.rb +6 -0
- data/lib/MLserver/settings.rb +3 -1
- data/lib/MLserver.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22e124eded055286605b8d9ba7a590695492e2c2b939248789c21e756ecccb29
|
4
|
+
data.tar.gz: 5ed4807343ab09b99b54c4744474378c84aed218722d009b58661fcc21a6dd54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eca4cf68f62a8657eb51707be102851effe47eec6f83ef36512a8e97de4adc7fccdd7d117aee58a0d6d505c8ba480eec5c97833a148a97465cf710648f6c3315
|
7
|
+
data.tar.gz: e078bf1f0e085ea495fff726df178715c038170e3a516e95a42c371ef4d036791dd48a5ce7811224c5fcdc5565672fee40edb28b2c77d8774faaf376b02e2ec4
|
data/bin/mlserver
CHANGED
@@ -11,6 +11,28 @@ s = {}
|
|
11
11
|
x = ArgsParser::Args.new(options: o, switches: s)
|
12
12
|
|
13
13
|
conf_file = x.data[0]
|
14
|
-
require_relative conf_file
|
15
14
|
|
16
|
-
|
15
|
+
if !conf_file
|
16
|
+
conf_file = "mlserver.conf.rb"
|
17
|
+
end
|
18
|
+
|
19
|
+
if File.directory?(conf_file)
|
20
|
+
conf_file = "#{conf_file}/mlserver.conf.rb"
|
21
|
+
end
|
22
|
+
|
23
|
+
if !File.exist?(conf_file)
|
24
|
+
STDERR.puts "Error: Conf file does not exist"
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
full_conf_file_path = File.expand_path(conf_file, Dir.pwd)
|
29
|
+
|
30
|
+
Dir.chdir(File.dirname full_conf_file_path)
|
31
|
+
|
32
|
+
require full_conf_file_path
|
33
|
+
|
34
|
+
begin
|
35
|
+
MLserver::Server.start()
|
36
|
+
rescue Interrupt
|
37
|
+
MLserver.settings.logger.log("\nReceived Interrupt, Exiting...", :error)
|
38
|
+
end
|
data/lib/MLserver/logger.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module MLserver
|
2
2
|
class Logger
|
3
|
-
@@log_levels = [:info, :warn, :error]
|
3
|
+
@@log_levels = [:info, :warn, :error, :traffic_in, :traffic_out]
|
4
4
|
|
5
|
-
def initialize(out:, err:, log_colors: {}, outputs: {error: :err})
|
5
|
+
def initialize(out:, err:, log_colors: {}, outputs: {error: :err}, levels_with_timestamp: [:traffic_in, :traffic_out])
|
6
6
|
@out = out
|
7
7
|
@err = err
|
8
8
|
@log_colors = log_colors
|
9
9
|
@outputs = outputs
|
10
|
+
@levels_with_timestamp = levels_with_timestamp
|
10
11
|
end
|
11
12
|
|
12
13
|
def log(message, level = :info)
|
@@ -16,6 +17,9 @@ module MLserver
|
|
16
17
|
if @log_colors[level]
|
17
18
|
message = message.color @log_colors[level]
|
18
19
|
end
|
20
|
+
|
21
|
+
message = "#{Time.now} | #{message}" if @levels_with_timestamp.include?(level)
|
22
|
+
|
19
23
|
out.puts message
|
20
24
|
end
|
21
25
|
|
@@ -38,13 +42,15 @@ module MLserver
|
|
38
42
|
def log_traffic(ip, direction, data)
|
39
43
|
symbol = (direction == :incoming ? "=>" : "<=")
|
40
44
|
|
41
|
-
log("#{format_ip_address ip} #{symbol} #{data}")
|
45
|
+
log("#{format_ip_address ip} #{symbol} #{data}", (direction == :incoming ? :traffic_in : :traffic_out))
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
45
49
|
dlcolors = {
|
46
50
|
warn: :yellow,
|
47
|
-
error: :red
|
51
|
+
error: :red,
|
52
|
+
traffic_in: :green,
|
53
|
+
traffic_out: :blue
|
48
54
|
}
|
49
55
|
|
50
56
|
DefaultLogger = Logger.new(out: STDOUT, err: STDERR, log_colors: dlcolors)
|
data/lib/MLserver/server.rb
CHANGED
@@ -103,6 +103,12 @@ module MLserver
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
+
if MLserver.settings.trim_urls && r.path != "/" && r.path[-1] == "/"
|
107
|
+
r.respond RedirectResponse.new(r.path[0..-2], type: 301, httpver: "HTTP/1.0").response
|
108
|
+
client.close
|
109
|
+
Thread.exit
|
110
|
+
end
|
111
|
+
|
106
112
|
begin
|
107
113
|
handler.run(r, client)
|
108
114
|
rescue => e
|
data/lib/MLserver/settings.rb
CHANGED
@@ -14,9 +14,11 @@ module MLserver
|
|
14
14
|
@ssl_additional_certs = []
|
15
15
|
@ssl_host = nil
|
16
16
|
@ssl_port = nil
|
17
|
+
@trim_urls = false
|
17
18
|
end
|
18
19
|
|
19
|
-
attr_accessor :host, :port, :handler, :logger, :force_host, :ssl, :ssl_key, :ssl_cert, :ssl_additional_certs, :ssl_host, :ssl_port
|
20
|
+
attr_accessor :host, :port, :handler, :logger, :force_host, :ssl, :ssl_key, :ssl_cert, :ssl_additional_certs, :ssl_host, :ssl_port,
|
21
|
+
:trim_urls
|
20
22
|
end
|
21
23
|
|
22
24
|
def self.settings
|
data/lib/MLserver.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mlserver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthias Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: argparse
|