minecraftctl 2.0.0 → 2.0.1

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.
data/Gemfile.lock CHANGED
@@ -4,10 +4,10 @@ GEM
4
4
  arrayfields (4.7.4)
5
5
  cgi_multipart_eof_fix (2.5.0)
6
6
  chronic (0.6.4)
7
- daemon (1.0.0)
7
+ daemon (1.1.0)
8
8
  daemons (1.1.4)
9
9
  diff-lcs (1.1.3)
10
- fastthread (1.0.1)
10
+ fastthread (1.0.7)
11
11
  fattr (2.2.0)
12
12
  gem_plugin (0.2.3)
13
13
  git (1.2.5)
@@ -16,7 +16,7 @@ GEM
16
16
  bundler (~> 1.0)
17
17
  git (>= 1.2.5)
18
18
  rake
19
- main (4.7.3)
19
+ main (4.7.7)
20
20
  arrayfields (~> 4.7.4)
21
21
  chronic (~> 0.6.2)
22
22
  fattr (~> 2.2.0)
@@ -27,7 +27,7 @@ GEM
27
27
  daemons (>= 1.0.3)
28
28
  fastthread (>= 1.0.1)
29
29
  gem_plugin (>= 0.2.3)
30
- rack (1.3.2)
30
+ rack (1.3.3)
31
31
  rake (0.9.2)
32
32
  rcov (0.9.10)
33
33
  reek (1.2.8)
@@ -44,15 +44,15 @@ GEM
44
44
  rspec-expectations (2.3.0)
45
45
  diff-lcs (~> 1.1.2)
46
46
  rspec-mocks (2.3.0)
47
- ruby2ruby (1.3.0)
47
+ ruby2ruby (1.3.1)
48
48
  ruby_parser (~> 2.0)
49
49
  sexp_processor (~> 3.0)
50
- ruby_parser (2.3.0)
50
+ ruby_parser (2.3.1)
51
51
  sexp_processor (~> 3.0)
52
- sexp_processor (3.0.6)
52
+ sexp_processor (3.0.7)
53
53
  sinatra (1.2.6)
54
54
  rack (~> 1.1)
55
- tilt (>= 1.2.2, < 2.0)
55
+ tilt (< 2.0, >= 1.2.2)
56
56
  tilt (1.3.3)
57
57
 
58
58
  PLATFORMS
data/README.rdoc CHANGED
@@ -46,6 +46,13 @@ Some cURL examples:
46
46
 
47
47
  == Changelog
48
48
 
49
+ === v2.0.1
50
+ * increased startup and command timeout
51
+ * startup and command timeout values are now configurable via -t and -s switches
52
+ * minecraftctl will not rise exception when command does not start with /
53
+ * initial minecraft server startup will now be logged
54
+ * shutdown messages logged in real time
55
+
49
56
  === v2.0.0
50
57
  * New cleaner API - more REST like
51
58
  * New API commands: pid, pid_file, dir, out...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.1
data/bin/minecraftctl CHANGED
@@ -22,6 +22,7 @@ Main do
22
22
 
23
23
  argument 'command' do
24
24
  description 'command to send to control server: try "/" for available commands'
25
+ validate{|cmd| cmd =~ /^\//}
25
26
  end
26
27
 
27
28
  argument 'arguments' do
@@ -33,13 +34,7 @@ Main do
33
34
  c = HTTPClient.new
34
35
 
35
36
  begin
36
- command = case params['command'].value
37
- when 'serverhelp'
38
- 'help'
39
- else
40
- params['command'].value
41
- end
42
-
37
+ command = params['command'].value
43
38
  args = params['arguments'].values
44
39
 
45
40
  if args.empty?
@@ -161,6 +161,20 @@ Main do
161
161
  argument_required
162
162
  end
163
163
 
164
+ option 'startup-timeout', 's' do
165
+ description 'time in seconds after which control server will exit with error while waiting for minecraft to start up'
166
+ default 120
167
+ cast :float
168
+ argument_required
169
+ end
170
+
171
+ option 'command-timeout', 't' do
172
+ description 'time in seconds after which control server will exit with error while waiting for minecraft console command to finish'
173
+ default 40
174
+ cast :float
175
+ argument_required
176
+ end
177
+
164
178
  argument 'minecraft-dir' do
165
179
  description 'directory path to mincraft server installation directory'
166
180
  argument_required
@@ -178,8 +192,12 @@ Main do
178
192
  Daemon.daemonize(pid_file, log_file)
179
193
  end
180
194
 
181
- minecraft = Minecraft.new(params['command'].value)
182
- minecraft.start
195
+ minecraft = Minecraft.new(params['command'].value, :startup_timeout => params['startup-timeout'].value, :command_timeout => params['command-timeout'].value)
196
+ TextCollector.for(minecraft) do
197
+ start
198
+ end.each do |msg|
199
+ puts msg
200
+ end
183
201
 
184
202
  sinatra = Sinatra.new
185
203
  sinatra.set :port, params['port'].value
data/lib/minecraft.rb CHANGED
@@ -102,11 +102,14 @@ class Minecraft
102
102
  end
103
103
  end
104
104
 
105
- def initialize(cmd)
105
+ def initialize(cmd, options)
106
106
  @cmd = cmd
107
107
  @in_queue = Queue.new
108
108
  @message_queue = MessageQueue.new
109
109
 
110
+ @startup_timeout = (options[:startup_timeout] or 120)
111
+ @command_timeout = (options[:command_timeout] or 40)
112
+
110
113
  @server_pid = nil
111
114
 
112
115
  @collector = nil
@@ -191,7 +194,7 @@ class Minecraft
191
194
  end
192
195
  end
193
196
 
194
- wait_msg do |m|
197
+ wait_msg(false, @startup_timeout) do |m|
195
198
  m.msg =~ /Done \(([^n]*)ns\)!/ or m.msg =~ /Minecraft exits/
196
199
  end
197
200
 
@@ -213,12 +216,11 @@ class Minecraft
213
216
  else
214
217
  command('stop') do
215
218
  time_operation("Server stop") do
219
+ wait_msg{|m| m.msg == "Minecraft exits"}
216
220
  Process.wait(@server_pid)
217
221
  @server_pid = nil
218
222
  log "Server stopped"
219
223
  end
220
-
221
- wait_msg{|m| m.msg == "Minecraft exits"}
222
224
  end
223
225
  end
224
226
  end
@@ -267,7 +269,8 @@ class Minecraft
267
269
  log "#{name} finished in #{(Time.now - start).to_f}"
268
270
  end
269
271
 
270
- def wait_msg(discard = false, timeout = 20)
272
+ def wait_msg(discard = false, timeout = nil)
273
+ timeout ||= @command_timeout
271
274
  Timeout::timeout(timeout) do
272
275
  loop do
273
276
  msg = @message_queue.pop
data/minecraftctl.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "minecraftctl"
8
- s.version = "2.0.0"
8
+ s.version = "2.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jakub Pastuszek"]
12
- s.date = "2011-09-26"
12
+ s.date = "2011-09-28"
13
13
  s.description = "Allows to send messages, start and stop Minecraft server"
14
14
  s.email = "jpastuszek@gmail.com"
15
15
  s.executables = ["minecraftctl", "minecraftctlserver", "minecraftctl", "minecraftctlserver"]
@@ -1,13 +1,17 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
+ $delay = ARGV[0]
4
+
3
5
  def out(line)
4
6
  STDOUT << line + "\n"
5
7
  STDOUT.flush
8
+ sleep $delay.to_f if $delay
6
9
  end
7
10
 
8
11
  def err(line)
9
12
  STDERR << line + "\n"
10
13
  STDERR.flush
14
+ sleep $delay.to_f if $delay
11
15
  end
12
16
 
13
17
  $expects = {}
@@ -90,7 +94,7 @@ expect 'stream' do
90
94
  end
91
95
 
92
96
  loop do
93
- cmd, *args = gets.split(' ')
97
+ cmd, *args = STDIN.gets.split(' ')
94
98
  if $expects.member? cmd
95
99
  $expects[cmd].call(*args)
96
100
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minecraftctl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 0
10
- version: 2.0.0
9
+ - 1
10
+ version: 2.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jakub Pastuszek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-26 00:00:00 Z
18
+ date: 2011-09-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement