rocket-server 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -39
- data/lib/rocket/server.rb +10 -2
- data/lib/rocket/server/cli.rb +16 -15
- data/lib/rocket/server/runner.rb +2 -2
- data/spec/spec_helper.rb +2 -1
- metadata +7 -7
data/Rakefile
CHANGED
@@ -1,43 +1,9 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
|
3
|
-
$:.unshift(File.expand_path('../../rocket/lib', __FILE__))
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
require 'rake/rdoctask'
|
2
|
+
require File.expand_path('../../load_paths', __FILE__)
|
6
3
|
require 'rocket/version'
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
5
|
+
$LIB_BASENAME = "rocket-server"
|
6
|
+
$LIB_FULLNAME = "#{$LIB_BASENAME}-#{Rocket.version}"
|
7
|
+
$LIB_TITLE = "Rocket Server #{Rocket.version}"
|
12
8
|
|
13
|
-
|
14
|
-
t.rcov = true
|
15
|
-
t.rspec_opts = %q[-I../rocket-core/lib -I../rocket/lib -Ilib -c -b]
|
16
|
-
t.rcov_opts = %q[-I../rocket-core/lib -I../rocket/lib -Ilib -T -x "spec"]
|
17
|
-
end
|
18
|
-
|
19
|
-
Rake::RDocTask.new do |rdoc|
|
20
|
-
rdoc.title = "Rocket Server #{Rocket.version}"
|
21
|
-
rdoc.rdoc_dir = 'rdoc'
|
22
|
-
rdoc.rdoc_files.include('README*')
|
23
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "Build current version as a rubygem"
|
27
|
-
task :build do
|
28
|
-
sh "gem build rocket-server.gemspec"
|
29
|
-
sh "mkdir -p pkg"
|
30
|
-
sh "mv rocket-server-*.gem pkg/"
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "Relase current version to rubygems.org"
|
34
|
-
task :release => :build do
|
35
|
-
sh "gem push pkg/rocket-server-#{Rocket.version}.gem"
|
36
|
-
end
|
37
|
-
|
38
|
-
desc "Perform installation via rubygems"
|
39
|
-
task :install => :build do
|
40
|
-
sh "gem install pkg/rocket-server-#{Rocket.version}.gem"
|
41
|
-
end
|
42
|
-
|
43
|
-
task :default => :spec
|
9
|
+
load File.expand_path('../../Rakefile.common', __FILE__)
|
data/lib/rocket/server.rb
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
begin
|
2
|
+
require 'fastthread'
|
3
|
+
rescue LoadError
|
4
|
+
puts "WARNING: You don't have fastthread gem installed. It's recommended" +
|
5
|
+
"to use it for better performance."
|
6
|
+
require 'thread'
|
7
|
+
end
|
8
|
+
|
1
9
|
require "konfigurator"
|
2
10
|
require 'eventmachine'
|
3
11
|
require 'em-websocket'
|
@@ -28,8 +36,8 @@ module Rocket
|
|
28
36
|
disable :verbose
|
29
37
|
disable :quiet
|
30
38
|
disable :daemon
|
31
|
-
set :pid,
|
32
|
-
set :log,
|
39
|
+
set :pid, "/var/run/rocket/server.pid"
|
40
|
+
set :log, "/var/log/rocket/server.log"
|
33
41
|
set :tls_options, {}
|
34
42
|
set :apps, []
|
35
43
|
set :plugins, []
|
data/lib/rocket/server/cli.rb
CHANGED
@@ -8,29 +8,30 @@ module Rocket
|
|
8
8
|
|
9
9
|
desc "Show used version of Rocket server"
|
10
10
|
def version
|
11
|
-
puts "Rocket v#{Rocket.version}"
|
11
|
+
puts "Rocket Server v#{Rocket.version}"
|
12
12
|
end
|
13
13
|
|
14
14
|
desc "Start Rocket server on given host and port"
|
15
|
-
opt "config", :short_name => "c", :
|
16
|
-
opt "host", :short_name => "h", :
|
17
|
-
opt "port", :short_name => "p", :
|
18
|
-
opt "plugins", :short_name => "r", :
|
19
|
-
opt "secure", :short_name => "s", :
|
20
|
-
opt "verbose", :short_name => "v", :
|
21
|
-
opt "quiet", :short_name => "q", :
|
22
|
-
opt "debug", :short_name => "D", :
|
23
|
-
opt "daemon", :short_name => "d", :
|
24
|
-
opt "pid", :short_name => "P", :
|
25
|
-
opt "log", :short_name => "l", :
|
15
|
+
opt "config", :short_name => "c", :desc => "Path to configuration file"
|
16
|
+
opt "host", :short_name => "h", :desc => "Specify server host"
|
17
|
+
opt "port", :short_name => "p", :desc => "Specify server port"
|
18
|
+
opt "plugins", :short_name => "r", :desc => "Require ruby extensions at runtime"
|
19
|
+
opt "secure", :short_name => "s", :desc => "Switch between wss/ws modes"
|
20
|
+
opt "verbose", :short_name => "v", :desc => "Increase verbosity"
|
21
|
+
opt "quiet", :short_name => "q", :desc => "Decrease verbosity"
|
22
|
+
opt "debug", :short_name => "D", :desc => "Run server in debug mode"
|
23
|
+
opt "daemon", :short_name => "d", :desc => "Run server as a daemon"
|
24
|
+
opt "pid", :short_name => "P", :desc => "Path to PID file (only when daemonized)"
|
25
|
+
opt "log", :short_name => "l", :desc => "Path to log file"
|
26
26
|
def start
|
27
|
-
|
27
|
+
config_file = params.delete('config') || '/etc/rocket/default.yml'
|
28
|
+
Rocket::Server.load_settings(config_file, symbolize_keys(params))
|
28
29
|
Rocket::Server::Runner.new(Rocket::Server.settings).start!
|
29
30
|
end
|
30
31
|
|
31
32
|
desc "Stop daemonized instance of Rocket server"
|
32
|
-
opt "config", :short_name => "c", :
|
33
|
-
opt "pid", :short_name => "P", :
|
33
|
+
opt "config", :short_name => "c", :desc => "Path to configuration file"
|
34
|
+
opt "pid", :short_name => "P", :desc => "Path to PID file (only when daemonized)"
|
34
35
|
def stop
|
35
36
|
Rocket::Server.load_settings(params.delete('config'), symbolize_keys(params))
|
36
37
|
|
data/lib/rocket/server/runner.rb
CHANGED
@@ -56,7 +56,7 @@ module Rocket
|
|
56
56
|
Process.kill(9, pid)
|
57
57
|
pid
|
58
58
|
end
|
59
|
-
rescue => e
|
59
|
+
rescue Object => e
|
60
60
|
# nothing to show
|
61
61
|
end
|
62
62
|
|
@@ -68,7 +68,7 @@ module Rocket
|
|
68
68
|
def save_pid
|
69
69
|
FileUtils.mkdir_p(File.dirname(pidfile))
|
70
70
|
File.open(pidfile, "w+"){|f| f.write("#{Process.pid}\n")}
|
71
|
-
rescue => e
|
71
|
+
rescue Object => e
|
72
72
|
puts e.to_s
|
73
73
|
exit 1
|
74
74
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocket-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Araneo Ltd.
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-29 00:00:00 +01:00
|
20
20
|
default_executable: rocket-server
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -27,12 +27,12 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - "="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
30
|
+
hash: 25
|
31
31
|
segments:
|
32
32
|
- 0
|
33
33
|
- 0
|
34
|
-
-
|
35
|
-
version: 0.0.
|
34
|
+
- 3
|
35
|
+
version: 0.0.3
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id001
|
38
38
|
- !ruby/object:Gem::Dependency
|