zashoku 1.5.4 → 1.5.5
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 +4 -4
- data/lib/constants.rb +1 -1
- data/lib/core/net/client.rb +1 -1
- data/lib/core/options.rb +7 -1
- data/lib/daemon.rb +3 -2
- data/lib/viewer.rb +3 -2
- data/lib/zashoku.rb +17 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 770d3ee1cf2f87e16048ee6b4e85c5386396ac57
|
4
|
+
data.tar.gz: 4eba5da2106507d67008149dd0ed87538dd3e8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be103708b5a862b9c26200c18c3eff09eab154efe10f7fd88b9bc7a704ee4997b148cd624aee1105cb6fdb2562b0d3841c1a3e4b76e2f4cb8ebcf02adf91698
|
7
|
+
data.tar.gz: 1aeec1a3e41021aa32d36d0e88536680df6ca666e343d1c0f8551961049d1740e147b0fb6d2d37eb7e1ec57316a1f72e6f7a5026b25e2144978a7318d58e43ad
|
data/lib/constants.rb
CHANGED
data/lib/core/net/client.rb
CHANGED
data/lib/core/options.rb
CHANGED
@@ -11,7 +11,8 @@ module Zashoku
|
|
11
11
|
server_command: nil,
|
12
12
|
generate: false,
|
13
13
|
template: nil,
|
14
|
-
generate_name: nil
|
14
|
+
generate_name: nil,
|
15
|
+
host: {}
|
15
16
|
}
|
16
17
|
|
17
18
|
parser = OptionParser.new do |opts|
|
@@ -33,6 +34,11 @@ module Zashoku
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
37
|
+
opts.on('-H HOST', '--host HOST', 'specify host') do |host|
|
38
|
+
options[:host][:host] = host.split(':').first
|
39
|
+
options[:host][:port] = host.split(':').last
|
40
|
+
end
|
41
|
+
|
36
42
|
opts.on_tail('-h', '--help', 'Show this message') do
|
37
43
|
puts opts
|
38
44
|
exit
|
data/lib/daemon.rb
CHANGED
@@ -32,7 +32,8 @@ module Zashoku
|
|
32
32
|
end
|
33
33
|
|
34
34
|
class Daemon
|
35
|
-
def initialize
|
35
|
+
def initialize(port:)
|
36
|
+
@port = port
|
36
37
|
@semaphore = Mutex.new
|
37
38
|
|
38
39
|
Zashoku.logger = Logger.new(STDOUT)
|
@@ -52,7 +53,7 @@ module Zashoku
|
|
52
53
|
|
53
54
|
def listen
|
54
55
|
lay_traps!
|
55
|
-
@server = Net::Server.new(
|
56
|
+
@server = Net::Server.new(@port)
|
56
57
|
@server.handler = method(:respond)
|
57
58
|
Zashoku.logger.info('server listening')
|
58
59
|
sleep
|
data/lib/viewer.rb
CHANGED
@@ -51,7 +51,8 @@ module Zashoku
|
|
51
51
|
|
52
52
|
COMMANDS = Zashoku::CConf[:core][:commands].merge(Zashoku::CConf[:app][:commands])
|
53
53
|
|
54
|
-
def initialize
|
54
|
+
def initialize(host:, port:)
|
55
|
+
@host, @port = host, port
|
55
56
|
@semaphore = Mutex.new
|
56
57
|
|
57
58
|
Zashoku.logger = Logger.new(
|
@@ -66,7 +67,7 @@ module Zashoku
|
|
66
67
|
Zashoku.conf.reload
|
67
68
|
|
68
69
|
# note: start daemon if not running
|
69
|
-
Zashoku.client = Net::Client.new(
|
70
|
+
Zashoku.client = Net::Client.new(host, port)
|
70
71
|
Zashoku.client.callbacks << method(:handle_event)
|
71
72
|
|
72
73
|
@server_modules = Zashoku.client.command('modules')
|
data/lib/zashoku.rb
CHANGED
@@ -18,49 +18,51 @@ module Zashoku
|
|
18
18
|
modules[message[:mod]].send(message[:meth], *message[:args])
|
19
19
|
end
|
20
20
|
|
21
|
+
|
21
22
|
def self.main(args)
|
22
23
|
@options = Options.parse(args)
|
24
|
+
host = @options[:host].key?(:host) ? @options[:host][:host] : Zashoku::CConf[:app][:net][:host]
|
25
|
+
port = @options[:host].key?(:port) ? @options[:host][:port] : Zashoku::CConf[:app][:net][:port]
|
26
|
+
|
23
27
|
Zashoku.modules = []
|
24
28
|
|
25
29
|
if @options[:generate]
|
26
30
|
Generator.generate(@options[:template], @options[:generate_name])
|
27
31
|
elsif @options[:server_command]
|
28
|
-
print command_server(@options[:server_command])[:payload]
|
32
|
+
print command_server(@options[:server_command], host, port)[:payload]
|
29
33
|
else
|
30
|
-
unless command_server('up?')[:status]
|
34
|
+
unless command_server('up?', host, port)[:status]
|
31
35
|
@options[:daemon] = true
|
32
|
-
command_server('start')
|
33
|
-
sleep(0.2) until command_server('up?')[:status]
|
36
|
+
command_server('start', host, port)
|
37
|
+
sleep(0.2) until command_server('up?', host, port)[:status]
|
34
38
|
end
|
35
|
-
Viewer.new
|
39
|
+
Viewer.new(host: host, port: port)
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
|
-
def self.start_daemon
|
43
|
+
def self.start_daemon(port)
|
40
44
|
if @options[:daemon]
|
41
45
|
fork {
|
42
46
|
Process.daemon()
|
43
|
-
Daemon.new
|
47
|
+
d = Daemon.new(port: port)
|
48
|
+
d.listen
|
44
49
|
}
|
45
50
|
else
|
46
|
-
Daemon.new
|
51
|
+
d = Daemon.new(port: port)
|
52
|
+
d.listen
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
50
|
-
def self.command_server(command)
|
56
|
+
def self.command_server(command, host, port)
|
51
57
|
case command
|
52
58
|
when 'start'
|
53
|
-
start_daemon
|
59
|
+
start_daemon(port)
|
54
60
|
when 'restart'
|
55
61
|
command_server('stop')
|
56
62
|
start_daemon
|
57
63
|
else
|
58
64
|
require_relative 'core/net/client'
|
59
|
-
Net::Client.command(
|
60
|
-
Zashoku::CConf[:app][:net][:host],
|
61
|
-
Zashoku::CConf[:app][:net][:port],
|
62
|
-
command
|
63
|
-
)
|
65
|
+
Net::Client.command(host, port, command)
|
64
66
|
end
|
65
67
|
end
|
66
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zashoku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- annacrombie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|