rhoconnect 4.0.0 → 4.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/CHANGELOG.md +8 -0
- data/Gemfile.lock +16 -18
- data/Rakefile +4 -4
- data/bench/benchapp/Rakefile +10 -16
- data/bench/blobapp/Rakefile +9 -18
- data/bench/distr_bench/distr_bench_main +1 -1
- data/bench/distr_bench/run_distr_client.sh +2 -1
- data/bench/lib/bench.rb +1 -1
- data/bench/lib/bench/cli.rb +2 -0
- data/bench/lib/bench/distr_runner.rb +5 -5
- data/bench/lib/bench/test_data.rb +2 -2
- data/bench/scripts/test_query_script.rb +7 -6
- data/bin/rhoconnect +2 -0
- data/bin/rhoconnect-benchmark +13 -1
- data/commands/redis/redis_download.rb +1 -1
- data/commands/rhoconnect/routes.rb +12 -0
- data/doc/authentication.txt +1 -1
- data/doc/command-line.txt +1 -1
- data/doc/deploying.txt +2 -2
- data/doc/migration.txt +21 -12
- data/doc/push-client-setup-android.txt +1 -1
- data/doc/push-client-setup-rps.txt +3 -1
- data/doc/supported-platforms.txt +14 -7
- data/examples/simple/Rakefile +0 -1
- data/generators/rhoconnect.rb +15 -3
- data/generators/templates/application/Rakefile +1 -2
- data/js-adapters/ballroom.js +36 -9
- data/js-adapters/node.rb +8 -2
- data/js-adapters/node_channel.rb +10 -6
- data/js-adapters/rhoconnect_helpers.js +4 -0
- data/js-adapters/router.js +5 -3
- data/js-adapters/server.js +1 -1
- data/lib/rhoconnect.rb +9 -5
- data/lib/rhoconnect/api_token.rb +1 -2
- data/lib/rhoconnect/client.rb +1 -1
- data/lib/rhoconnect/controller/js_base.rb +7 -2
- data/lib/rhoconnect/model/base.rb +1 -1
- data/lib/rhoconnect/predefined_adapters/controllers/js/rho_internal_js_bench_adapter_controller.js +12 -0
- data/lib/rhoconnect/predefined_adapters/models/js/rho_internal_js_bench_adapter.js +107 -0
- data/lib/rhoconnect/source.rb +5 -0
- data/lib/rhoconnect/store.rb +3 -0
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect/web-console/server.rb +1 -2
- data/rhoconnect.gemspec +0 -1
- data/spec/apps/jstestapp/Rakefile +1 -0
- data/spec/apps/jstestapp/config.ru +16 -0
- data/spec/apps/jstestapp/controllers/js/application_controller.js +18 -0
- data/spec/apps/jstestapp/settings/license.key +1 -0
- data/spec/apps/jstestapp/settings/settings.yml +13 -0
- data/spec/controllers/js_base_spec.rb +129 -97
- data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +111 -0
- data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +44 -0
- data/spec/spec_helper.rb +4 -0
- data/tasks/redis.rake +9 -127
- metadata +19 -20
- data/lib/rhoconnect/tasks.rb +0 -315
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'rack/test'
|
2
|
+
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
3
|
+
require File.join(File.dirname(__FILE__),'..','..','lib','rhoconnect','server.rb')
|
4
|
+
|
5
|
+
describe "Rhoconnect::RhoInternalJsBenchAdapterController" do
|
6
|
+
include Rack::Test::Methods
|
7
|
+
include Rhoconnect
|
8
|
+
|
9
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
10
|
+
def app
|
11
|
+
@app ||= Rack::URLMap.new Rhoconnect.url_map
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
Rhoconnect::Server.set :environment, :test
|
16
|
+
Rhoconnect::Server.set :secret, "secure!"
|
17
|
+
Rhoconnect.use_node = true
|
18
|
+
Rhoconnect.bootstrap(get_testapp_path)
|
19
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:each) do
|
23
|
+
Rhoconnect::Store.flush_all
|
24
|
+
Rhoconnect::Node.kill_process
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should call query method" do
|
28
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
29
|
+
last_response.should be_ok
|
30
|
+
body = JSON.parse(last_response.body)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should call create method" do
|
34
|
+
hsh = {'create'=>{'1'=>{'mockId'=>'1','name'=>'testname','price'=>'$199'}}}
|
35
|
+
post '/app/v1/RhoInternalJsBenchAdapter', hsh,{Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
36
|
+
last_response.should be_ok
|
37
|
+
|
38
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
39
|
+
body = JSON.parse(last_response.body)
|
40
|
+
body[5]["insert"]["mockId"]["mockId"].should == "1"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should call update method" do
|
44
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
45
|
+
body = JSON.parse(last_response.body)
|
46
|
+
body[4]["total_count"].should == 0
|
47
|
+
|
48
|
+
hsh = {'create'=>{'1'=>{'mockId'=>'1','name'=>'testname','price'=>'$199'}}}
|
49
|
+
post '/app/v1/RhoInternalJsBenchAdapter', hsh,{Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
50
|
+
last_response.should be_ok
|
51
|
+
|
52
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
53
|
+
body = JSON.parse(last_response.body)
|
54
|
+
token = last_response.headers["X-Rhoconnect-PAGE-TOKEN"]
|
55
|
+
count = body[4]["total_count"]
|
56
|
+
count.should == 1
|
57
|
+
|
58
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {:token=>token}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
59
|
+
body = JSON.parse(last_response.body)
|
60
|
+
count = body[4]["total_count"]
|
61
|
+
count.should == 1
|
62
|
+
|
63
|
+
hsh = {'update'=>{'mockId'=>'1','name'=>'updatename'}}
|
64
|
+
put '/app/v1/RhoInternalJsBenchAdapter/mockId',hsh, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
65
|
+
last_response.should be_ok
|
66
|
+
|
67
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
68
|
+
body = JSON.parse(last_response.body)
|
69
|
+
puts "body is #{body}"
|
70
|
+
token = last_response.headers["X-Rhoconnect-PAGE-TOKEN"]
|
71
|
+
#body[5]["insert"]["mockId"]["name"].should == "updatename"
|
72
|
+
|
73
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {:token=>token}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
74
|
+
body = JSON.parse(last_response.body)
|
75
|
+
puts "body is #{body}"
|
76
|
+
last_response.should be_ok
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should call delete method" do
|
80
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
81
|
+
body = JSON.parse(last_response.body)
|
82
|
+
body[4]["total_count"].should == 0
|
83
|
+
|
84
|
+
hsh = {'create'=>{'1'=>{'mockId'=>'1','name'=>'testname','price'=>'$199'}}}
|
85
|
+
post '/app/v1/RhoInternalJsBenchAdapter', hsh,{Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
86
|
+
last_response.should be_ok
|
87
|
+
|
88
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
89
|
+
body = JSON.parse(last_response.body)
|
90
|
+
token = last_response.headers["X-Rhoconnect-PAGE-TOKEN"]
|
91
|
+
count = body[4]["total_count"]
|
92
|
+
count.should == 1
|
93
|
+
|
94
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {:token => token}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
95
|
+
body = JSON.parse(last_response.body)
|
96
|
+
count = body[4]["total_count"]
|
97
|
+
count.should == 1
|
98
|
+
|
99
|
+
delete '/app/v1/RhoInternalJsBenchAdapter/1',{}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
100
|
+
last_response.should be_ok
|
101
|
+
|
102
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
103
|
+
body = JSON.parse(last_response.body)
|
104
|
+
token = last_response.headers["X-Rhoconnect-PAGE-TOKEN"]
|
105
|
+
|
106
|
+
get '/app/v1/RhoInternalJsBenchAdapter', {:token => token}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
107
|
+
body = JSON.parse(last_response.body)
|
108
|
+
body[4]["total_count"].should == 0
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
2
|
+
require File.join(File.dirname(__FILE__),'..','..','lib','rhoconnect','server.rb')
|
3
|
+
|
4
|
+
describe "Rhoconnect::RhoInternalJsBenchAdapter" do
|
5
|
+
include Rhoconnect
|
6
|
+
|
7
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
8
|
+
before(:each) do
|
9
|
+
Rhoconnect::Server.set :environment, :test
|
10
|
+
Rhoconnect::Server.set :secret, "secure!"
|
11
|
+
Rhoconnect.use_node = true
|
12
|
+
Rhoconnect.bootstrap(get_testapp_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def app
|
16
|
+
@app ||= Rack::URLMap.new Rhoconnect.url_map
|
17
|
+
end
|
18
|
+
|
19
|
+
after(:each) do
|
20
|
+
Rhoconnect::Store.flush_all
|
21
|
+
Rhoconnect::Node.kill_process
|
22
|
+
#Source.valid_doctypes.delete('tmpdoc'.to_sym)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should call login method from model" do
|
26
|
+
rho_int = RhoInternalJsBenchAdapter.new(Source.load('RhoInternalJsBenchAdapter', {:app_id => @a.id, :user_id => @u.id}))
|
27
|
+
res = rho_int.login
|
28
|
+
res.should == true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should call logoff method from model" do
|
32
|
+
rho_int = RhoInternalJsBenchAdapter.new(Source.load('RhoInternalJsBenchAdapter', {:app_id => @a.id, :user_id => @u.id}))
|
33
|
+
res = rho_int.logoff
|
34
|
+
res.should == true
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should call query method from model" do
|
38
|
+
rho_int = RhoInternalJsBenchAdapter.new(Source.load('RhoInternalJsBenchAdapter', {:app_id => @a.id, :user_id => @u.id}))
|
39
|
+
res = rho_int.query
|
40
|
+
res.should == true
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -71,6 +71,10 @@ module TestHelpers
|
|
71
71
|
File.expand_path(File.join(File.dirname(__FILE__),'apps','rhotestapp'))
|
72
72
|
end
|
73
73
|
|
74
|
+
def get_jstestapp_path
|
75
|
+
File.expand_path(File.join(File.dirname(__FILE__),'apps','jstestapp'))
|
76
|
+
end
|
77
|
+
|
74
78
|
def get_emptyapp_path
|
75
79
|
File.expand_path(File.join(File.dirname(__FILE__),'apps','emptyapp'))
|
76
80
|
end
|
data/tasks/redis.rake
CHANGED
@@ -1,105 +1,12 @@
|
|
1
1
|
# Inspired by rabbitmq.rake the Redbox project at http://github.com/rick/redbox/tree/master
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
require_relative '../lib/rhoconnect/utilities'
|
3
|
+
require_relative '../commands/utilities/redis_runner'
|
4
|
+
include Utilities
|
6
5
|
include Rake::DSL
|
7
6
|
|
8
|
-
REDIS_RELEASE = "2.
|
9
|
-
|
10
|
-
# See: http://rbjl.net/35-how-to-properly-check-for-your-ruby-interpreter-version-and-os
|
11
|
-
def windows?
|
12
|
-
RbConfig::CONFIG['host_os'] =~ /(win|w)32$/
|
13
|
-
end
|
14
|
-
|
15
|
-
if windows?
|
16
|
-
$redis_ver = "redis-#{REDIS_RELEASE}"
|
17
|
-
$redis_zip = "C:/#{$redis_ver}.zip"
|
18
|
-
$redis_dest = "C:/"
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def redis_home
|
23
|
-
ENV['REDIS_HOME'] || File.join($redis_dest,$redis_ver)
|
24
|
-
end
|
25
|
-
|
26
|
-
def mk_bin_dir(bin_dir)
|
27
|
-
begin
|
28
|
-
mkdir_p bin_dir unless File.exists?(bin_dir)
|
29
|
-
rescue
|
30
|
-
puts "Can't create #{bin_dir}, maybe you need to run command as root?"
|
31
|
-
exit 1
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class RedisRunner
|
36
|
-
|
37
|
-
def self.prefix
|
38
|
-
"/usr/local/"
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.redisdir
|
42
|
-
"/tmp/redis/"
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.redisconfdir
|
46
|
-
server_dir = File.dirname(`which redis-server`)
|
47
|
-
conf_file = "#{RedisRunner.prefix}etc/redis.conf"
|
48
|
-
unless File.exists? conf_file
|
49
|
-
conf_file = "#{server_dir}/redis.conf"
|
50
|
-
end
|
51
|
-
conf_file
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.dtach_socket
|
55
|
-
'/tmp/redis.dtach'
|
56
|
-
end
|
57
|
-
|
58
|
-
# Just check for existance of dtach socket
|
59
|
-
def self.running?
|
60
|
-
File.exists? dtach_socket
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.start
|
64
|
-
if windows?
|
65
|
-
puts "Starting redis in a new window..."
|
66
|
-
sh "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
|
67
|
-
"redis-server not installed on your path, please install redis."
|
68
|
-
elsif defined?(JRUBY_VERSION)
|
69
|
-
puts "Starting redis ..."
|
70
|
-
sh "redis-server #{redisconfdir}"
|
71
|
-
else
|
72
|
-
puts 'Detach with Ctrl+\ Re-attach with rake redis:attach'
|
73
|
-
sleep 1
|
74
|
-
command = "dtach -A #{dtach_socket} redis-server #{redisconfdir}"
|
75
|
-
sh command
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# this function is used with Rhostudio where there is no terminal
|
80
|
-
def self.startbg
|
81
|
-
if windows?
|
82
|
-
puts "Starting redis in a new window..."
|
83
|
-
sh "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
|
84
|
-
"redis-server not installed on your path, please install redis."
|
85
|
-
else
|
86
|
-
puts "Starting redis ..."
|
87
|
-
system("redis-server #{redisconfdir} &")
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.attach
|
92
|
-
exec "dtach -a #{dtach_socket}"
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.stop
|
96
|
-
Redis.new.shutdown rescue nil
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|
7
|
+
REDIS_RELEASE = "2.6.14"
|
100
8
|
|
101
9
|
namespace :redis do
|
102
|
-
|
103
10
|
desc 'About redis'
|
104
11
|
task :about do
|
105
12
|
puts "\nSee http://redis.io/ for information about redis.\n\n"
|
@@ -137,11 +44,9 @@ namespace :redis do
|
|
137
44
|
ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "#{RedisRunner.prefix}bin"
|
138
45
|
|
139
46
|
mk_bin_dir(bin_dir)
|
140
|
-
|
141
47
|
%w(redis-benchmark redis-cli redis-server).each do |bin|
|
142
48
|
sh "cp /tmp/redis/src/#{bin} #{bin_dir}"
|
143
49
|
end
|
144
|
-
|
145
50
|
puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}"
|
146
51
|
|
147
52
|
ENV['PREFIX'] and conf_dir = "#{ENV['PREFIX']}/etc" or conf_dir = "#{RedisRunner.prefix}etc"
|
@@ -162,40 +67,17 @@ namespace :redis do
|
|
162
67
|
|
163
68
|
desc "Download package"
|
164
69
|
task :download do
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
Net::HTTP.start("cloud.github.com") do |http|
|
171
|
-
resp = http.get("/downloads/dmajkic/redis/#{$redis_ver}-win32-win64.zip")
|
172
|
-
open($redis_zip, "wb") do |file|
|
173
|
-
file.write(resp.body)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
Zip::ZipFile.open($redis_zip) do |zip_file|
|
178
|
-
zip_file.each do |f|
|
179
|
-
f_path = File.join(redis_home, f.name)
|
180
|
-
FileUtils.mkdir_p(File.dirname(f_path))
|
181
|
-
zip_file.extract(f, f_path) { true }
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
FileUtils.mv Dir.glob(File.join(redis_home,'32bit','*')), redis_home
|
186
|
-
FileUtils.rm_rf File.join(redis_home, '64bit')
|
187
|
-
FileUtils.rm_f $redis_zip
|
70
|
+
unless windows?
|
71
|
+
system 'rm -rf /tmp/redis/' if File.exists?("#{RedisRunner.redisdir}")
|
72
|
+
system 'git clone git://github.com/antirez/redis.git /tmp/redis -n'
|
73
|
+
system "cd #{RedisRunner.redisdir} && git reset --hard && git checkout #{REDIS_RELEASE}"
|
188
74
|
else
|
189
|
-
|
190
|
-
sh 'git clone git://github.com/antirez/redis.git /tmp/redis -n'
|
191
|
-
sh "cd #{RedisRunner.redisdir} && git reset --hard && git checkout #{REDIS_RELEASE}"
|
75
|
+
puts "Not implemented on Windows"
|
192
76
|
end
|
193
77
|
end
|
194
|
-
|
195
78
|
end
|
196
79
|
|
197
80
|
namespace :dtach do
|
198
|
-
|
199
81
|
desc 'About dtach'
|
200
82
|
task :about do
|
201
83
|
puts "\nSee http://dtach.sourceforge.net/ for information about dtach.\n\n"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhoconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -107,22 +107,6 @@ dependencies:
|
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 0.9.4
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: uuidtools
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 2.1.1
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 2.1.1
|
126
110
|
- !ruby/object:Gem::Dependency
|
127
111
|
name: connection_pool
|
128
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -594,9 +578,10 @@ files:
|
|
594
578
|
- lib/rhoconnect/web-console/controllers/admins.js
|
595
579
|
- lib/rhoconnect/web-console/templates/index.erb
|
596
580
|
- lib/rhoconnect/web-console/templates/jqplot.erb
|
597
|
-
- lib/rhoconnect/tasks.rb
|
598
581
|
- lib/rhoconnect/read_state.rb
|
599
582
|
- lib/rhoconnect/predefined_adapters/bench_adapter.rb
|
583
|
+
- lib/rhoconnect/predefined_adapters/models/js/rho_internal_js_bench_adapter.js
|
584
|
+
- lib/rhoconnect/predefined_adapters/controllers/js/rho_internal_js_bench_adapter_controller.js
|
600
585
|
- lib/rhoconnect/ping.rb
|
601
586
|
- lib/rhoconnect/bulk_data.rb
|
602
587
|
- lib/rhoconnect/source.rb
|
@@ -659,6 +644,8 @@ files:
|
|
659
644
|
- spec/perf/store_perf_spec.rb
|
660
645
|
- spec/rhoconnect_spec.rb
|
661
646
|
- spec/user_spec.rb
|
647
|
+
- spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb
|
648
|
+
- spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb
|
662
649
|
- spec/models/js_base_spec.rb
|
663
650
|
- spec/server/cors_spec.rb
|
664
651
|
- spec/server/x_domain_session_wrapper_spec.rb
|
@@ -732,6 +719,11 @@ files:
|
|
732
719
|
- spec/ping/apple_spec.rb
|
733
720
|
- spec/ping/gcm_spec.rb
|
734
721
|
- spec/license_spec.rb
|
722
|
+
- spec/apps/jstestapp/settings/settings.yml
|
723
|
+
- spec/apps/jstestapp/settings/license.key
|
724
|
+
- spec/apps/jstestapp/config.ru
|
725
|
+
- spec/apps/jstestapp/controllers/js/application_controller.js
|
726
|
+
- spec/apps/jstestapp/Rakefile
|
735
727
|
- spec/apps/emptyapp/application.rb
|
736
728
|
- spec/apps/emptyapp/settings/settings.yml
|
737
729
|
- spec/apps/emptyapp/settings/license.key
|
@@ -770,7 +762,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
770
762
|
version: '0'
|
771
763
|
segments:
|
772
764
|
- 0
|
773
|
-
hash: -
|
765
|
+
hash: -3033428230071358530
|
774
766
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
775
767
|
none: false
|
776
768
|
requirements:
|
@@ -821,6 +813,8 @@ test_files:
|
|
821
813
|
- spec/perf/store_perf_spec.rb
|
822
814
|
- spec/rhoconnect_spec.rb
|
823
815
|
- spec/user_spec.rb
|
816
|
+
- spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb
|
817
|
+
- spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb
|
824
818
|
- spec/models/js_base_spec.rb
|
825
819
|
- spec/server/cors_spec.rb
|
826
820
|
- spec/server/x_domain_session_wrapper_spec.rb
|
@@ -894,6 +888,11 @@ test_files:
|
|
894
888
|
- spec/ping/apple_spec.rb
|
895
889
|
- spec/ping/gcm_spec.rb
|
896
890
|
- spec/license_spec.rb
|
891
|
+
- spec/apps/jstestapp/settings/settings.yml
|
892
|
+
- spec/apps/jstestapp/settings/license.key
|
893
|
+
- spec/apps/jstestapp/config.ru
|
894
|
+
- spec/apps/jstestapp/controllers/js/application_controller.js
|
895
|
+
- spec/apps/jstestapp/Rakefile
|
897
896
|
- spec/apps/emptyapp/application.rb
|
898
897
|
- spec/apps/emptyapp/settings/settings.yml
|
899
898
|
- spec/apps/emptyapp/settings/license.key
|
data/lib/rhoconnect/tasks.rb
DELETED
@@ -1,315 +0,0 @@
|
|
1
|
-
require 'zip/zip'
|
2
|
-
require 'uri'
|
3
|
-
$:.unshift File.dirname(__FILE__)
|
4
|
-
require 'utilities'
|
5
|
-
|
6
|
-
DEPRECATION_MSG = "\n" +
|
7
|
-
"*** Warning: As of version 4.0 of rhoconnect, the rake command will be deprecated. ***\n" +
|
8
|
-
"*** Use the corresponding rhoconnect commands instead. ***\n" +
|
9
|
-
"*** Type 'rhoconnect help' for more information on these commands. ***\n" +
|
10
|
-
"\n"
|
11
|
-
|
12
|
-
puts DEPRECATION_MSG if $0.include? 'rake'
|
13
|
-
|
14
|
-
namespace :rhoconnect do
|
15
|
-
include Utilities
|
16
|
-
|
17
|
-
task :config do
|
18
|
-
$settings = load_settings(File.join('settings','settings.yml'))
|
19
|
-
$env = (ENV['RHO_ENV'] || ENV['RACK_ENV'] || :development).to_sym
|
20
|
-
uri = URI.parse($settings[$env][:syncserver])
|
21
|
-
$url = "#{uri.scheme}://#{uri.host}"
|
22
|
-
$url = "#{$url}:#{uri.port}" if uri.port && uri.port != 80
|
23
|
-
$host = uri.host
|
24
|
-
$port = uri.port
|
25
|
-
$appname = $settings[$env][:syncserver].split('/').last
|
26
|
-
$token_file = File.join(ENV['HOME'],'.rhoconnect_token')
|
27
|
-
$token = File.read($token_file) if File.exist?($token_file)
|
28
|
-
end
|
29
|
-
|
30
|
-
task :dtach_installed do
|
31
|
-
if !windows? and (`which dtach` == '')
|
32
|
-
puts "WARNING: dtach not installed or not on path, some tasks will not work!"
|
33
|
-
puts " Install with '[sudo] rake dtach:install'"
|
34
|
-
exit
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
desc "Reset the rhoconnect database (you will need to run rhoconnect:get_token afterwards)"
|
39
|
-
task :reset => :config do
|
40
|
-
confirm = ask " Are you sure? Resetting will remove all data!\n It will also return an error code to all\n existing devices when they connect! (yes/no): "
|
41
|
-
if confirm == 'yes'
|
42
|
-
RestClient.post("#{$url}/api/admin/reset", { :api_token => $token })
|
43
|
-
puts "Database reset."
|
44
|
-
else
|
45
|
-
puts "Cancelling."
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "Fetches current api token from rhoconnect"
|
50
|
-
task :get_token => :config do
|
51
|
-
password = ''
|
52
|
-
login = ask "admin login: "
|
53
|
-
begin
|
54
|
-
system "stty -echo"
|
55
|
-
password = ask "\nadmin password: "
|
56
|
-
system "stty echo"
|
57
|
-
rescue NoMethodError, Interrupt
|
58
|
-
system "stty echo"
|
59
|
-
exit
|
60
|
-
end
|
61
|
-
puts ''
|
62
|
-
begin
|
63
|
-
$token = RestClient.post("#{$url}/api/admin/login", { :login => login, :password => password})
|
64
|
-
rescue
|
65
|
-
puts "Login failed."
|
66
|
-
exit
|
67
|
-
end
|
68
|
-
File.open($token_file,'w') {|f| f.write $token}
|
69
|
-
puts "Token is saved in: #{$token_file}"
|
70
|
-
end
|
71
|
-
|
72
|
-
desc "Clean rhoconnect, get token, and create new user"
|
73
|
-
task :clean_start => [:get_token, :reset, :get_token, :create_user]
|
74
|
-
|
75
|
-
desc "Alias for `rake rhoconnect:stop; rake rhoconnect:start`"
|
76
|
-
task :restart => [:stop, :start]
|
77
|
-
|
78
|
-
desc "Creates and subscribes user for application in rhoconnect"
|
79
|
-
task :create_user => :config do
|
80
|
-
password = ''
|
81
|
-
login = ask "new user login: "
|
82
|
-
begin
|
83
|
-
system "stty -echo"
|
84
|
-
password = ask "\nnew user password: "
|
85
|
-
system "stty echo"
|
86
|
-
rescue NoMethodError, Interrupt
|
87
|
-
system "stty echo"
|
88
|
-
exit
|
89
|
-
end
|
90
|
-
puts ''
|
91
|
-
RestClient.post("#{$url}/api/user/create_user", { :api_token => $token, :attributes => {:login => login, :password => password}})
|
92
|
-
end
|
93
|
-
|
94
|
-
desc "Deletes a user from rhoconnect"
|
95
|
-
task :delete_user => :config do
|
96
|
-
login = ask "user to delete: "
|
97
|
-
RestClient.post("#{$url}/api/user/delete_user", { :api_token => $token, :user_id => login })
|
98
|
-
end
|
99
|
-
|
100
|
-
desc "Deletes a device from rhoconnect"
|
101
|
-
task :delete_device => :config do
|
102
|
-
user_id = ask "device's user_id: "
|
103
|
-
device_id = ask "device to delete: "
|
104
|
-
RestClient.post("#{$url}/api/client/delete_client", { :api_token => $token, :user_id => user_id, :client_id => device_id})
|
105
|
-
end
|
106
|
-
|
107
|
-
desc "Sets the admin password"
|
108
|
-
task :set_admin_password => :get_token do
|
109
|
-
new_pass,new_pass_confirm = '',''
|
110
|
-
begin
|
111
|
-
system "stty -echo"
|
112
|
-
new_pass = ask "\nnew admin password: "
|
113
|
-
new_pass_confirm = ask "\nconfirm new admin password: "
|
114
|
-
system "stty echo"
|
115
|
-
rescue NoMethodError, Interrupt
|
116
|
-
system "stty echo"
|
117
|
-
exit
|
118
|
-
end
|
119
|
-
if new_pass == ''
|
120
|
-
puts "\nNew password can't be empty."
|
121
|
-
elsif new_pass == new_pass_confirm
|
122
|
-
puts ""
|
123
|
-
admin_user = 'rhoadmin'
|
124
|
-
RestClient.put("#{$url}/rc/#{Rhoconnect::API_VERSION}/users/#{admin_user}", {:app_name => $appname, :api_token => $token,
|
125
|
-
:attributes => {:new_password => new_pass}})
|
126
|
-
else
|
127
|
-
puts "\nNew password and confirmation must match."
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
desc "Reset source refresh time"
|
132
|
-
task :reset_refresh => :config do
|
133
|
-
user = ask "user: "
|
134
|
-
source_name = ask "source name: "
|
135
|
-
RestClient.put("#{$url}/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{user}/sources/#{source_name}", {:api_token => $token})
|
136
|
-
end
|
137
|
-
|
138
|
-
begin
|
139
|
-
require 'rspec/core/rake_task'
|
140
|
-
|
141
|
-
desc "Run source adapter specs"
|
142
|
-
task :spec do
|
143
|
-
files = File.join('spec','**','*_spec.rb')
|
144
|
-
puts "files loaded are ****** #{files}"
|
145
|
-
RSpec::Core::RakeTask.new('rhoconnect:spec') do |t|
|
146
|
-
t.pattern = FileList[files]
|
147
|
-
t.rspec_opts = %w(-fn -b --color)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
rescue Exception => e
|
151
|
-
puts "Run source adapter specs error: #{e.inspect}"
|
152
|
-
end
|
153
|
-
|
154
|
-
desc "Start rhoconnect server"
|
155
|
-
task :start => :dtach_installed do
|
156
|
-
cmd = (jruby?) ? trinidad? : (thin? || mongrel? || report_missing_server)
|
157
|
-
if windows?
|
158
|
-
puts 'Starting rhoconnect...'
|
159
|
-
system("#{cmd} config.ru -P #{rhoconnect_pid}")
|
160
|
-
elsif jruby?
|
161
|
-
puts 'Starting rhoconnect in jruby environment...'
|
162
|
-
system("#{cmd} -r config.ru")
|
163
|
-
else
|
164
|
-
puts 'Detach with Ctrl+\ Re-attach with rake rhoconnect:attach'
|
165
|
-
sleep 2
|
166
|
-
system "dtach -A #{rhoconnect_socket} #{cmd} config.ru -P #{rhoconnect_pid}"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
# desc "Start rhoconnect server in bg mode (Rhostudio) - this is an internal command"
|
171
|
-
task :startbg do
|
172
|
-
cmd = (jruby?) ? trinidad? : (thin? || mongrel? || report_missing_server)
|
173
|
-
require 'win32/process' if windows?
|
174
|
-
|
175
|
-
p1 = Process.fork {
|
176
|
-
if windows?
|
177
|
-
puts 'Starting rhoconnect ...'
|
178
|
-
system("#{cmd} config.ru -P #{rhoconnect_pid}")
|
179
|
-
elsif jruby?
|
180
|
-
puts 'Starting rhoconnect in jruby environment...'
|
181
|
-
system("#{cmd} -r config.ru")
|
182
|
-
else
|
183
|
-
system("bundle exec #{cmd} config.ru -P #{rhoconnect_pid}")
|
184
|
-
end
|
185
|
-
}
|
186
|
-
Process.detach(p1)
|
187
|
-
|
188
|
-
exit
|
189
|
-
end
|
190
|
-
|
191
|
-
# desc "Start rhoconnect server in debug mode (Rhostudio) - this is an internal command"
|
192
|
-
task :startdebug do
|
193
|
-
cmd = (jruby?) ? trinidad? : (thin? || mongrel? || report_missing_server)
|
194
|
-
ENV['DEBUG'] = 'yes'
|
195
|
-
require 'win32/process' if windows?
|
196
|
-
|
197
|
-
p1 = Process.fork {
|
198
|
-
if windows?
|
199
|
-
puts 'Starting rhoconnect ...'
|
200
|
-
system("#{cmd} config.ru -P #{rhoconnect_pid}")
|
201
|
-
elsif jruby?
|
202
|
-
puts 'Starting rhoconnect in jruby environment...'
|
203
|
-
system("#{cmd} -r config.ru")
|
204
|
-
else
|
205
|
-
system("bundle exec #{cmd} config.ru -P #{rhoconnect_pid}")
|
206
|
-
end
|
207
|
-
}
|
208
|
-
Process.detach(p1)
|
209
|
-
|
210
|
-
exit
|
211
|
-
end
|
212
|
-
|
213
|
-
desc "run rhoconnect console"
|
214
|
-
task :console, :environment do |t, args|
|
215
|
-
if RedisRunner.running?
|
216
|
-
application_file = ruby19? ? './application' : 'application'
|
217
|
-
#load development environment by default
|
218
|
-
ENV['RACK_ENV'] = args[:environment] || 'development'
|
219
|
-
system "irb -rubygems -r #{File.join(File.dirname(__FILE__),'console')} " +
|
220
|
-
"-r #{File.dirname(__FILE__)} " +
|
221
|
-
"-r #{application_file}"
|
222
|
-
else
|
223
|
-
puts "Redis is not running. Please start it by running 'rake redis:start' command."
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
desc "Stop rhoconnect server"
|
228
|
-
task :stop => :dtach_installed do
|
229
|
-
if windows?
|
230
|
-
File.delete "#{rhoconnect_pid}" if system("FOR /F %A in (#{rhoconnect_pid}) do taskkill /F /PID %A")
|
231
|
-
else
|
232
|
-
if File.exist?("#{rhoconnect_pid}")
|
233
|
-
pid = `cat #{rhoconnect_pid}`
|
234
|
-
puts "Sending a QUIT signal to process #{pid}"
|
235
|
-
system "kill -3 #{pid}"
|
236
|
-
count = 0
|
237
|
-
loop do
|
238
|
-
sleep 1
|
239
|
-
count += 1
|
240
|
-
exit if !File.exist?("#{rhoconnect_pid}")
|
241
|
-
break if count >= 5
|
242
|
-
end
|
243
|
-
puts "Process #{pid} is still running. Sending a KILL signal to it ..."
|
244
|
-
system "kill -9 #{pid}"
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
desc "Attach to rhoconnect console"
|
250
|
-
task :attach => :dtach_installed do
|
251
|
-
system "dtach -a #{rhoconnect_socket}" unless windows?
|
252
|
-
end
|
253
|
-
|
254
|
-
desc "Launch the web console in a browser - uses :syncserver: in settings.yml"
|
255
|
-
task :web => :config do
|
256
|
-
windows? ? sh("start #{$url}") : sh("open #{$url}")
|
257
|
-
end
|
258
|
-
|
259
|
-
desc "Flush data store - WARNING: THIS REMOVES ALL DATA IN RHOCONNECT"
|
260
|
-
task :flushdb => :config do
|
261
|
-
puts "*** WARNING: THIS WILL REMOVE ALL DATA FROM YOUR REDIS STORE ***"
|
262
|
-
confirm = ask "Are you sure (please answer yes/no)? "
|
263
|
-
if confirm == 'yes'
|
264
|
-
Redis.new.flushdb
|
265
|
-
puts "Database flushed..."
|
266
|
-
else
|
267
|
-
puts "Aborted..."
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
desc "Generate a cryptographically secure secret session key"
|
272
|
-
task :secret do
|
273
|
-
begin
|
274
|
-
require 'securerandom'
|
275
|
-
puts SecureRandom.hex(64)
|
276
|
-
rescue LoadError
|
277
|
-
puts "Missing secure random generator. Try running `rake secret` in a rails application instead."
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
desc "Build executable WAR file to be used in Java App Servers"
|
282
|
-
task :war do
|
283
|
-
if jruby? then
|
284
|
-
puts "building the WAR file"
|
285
|
-
if not File::exists? "config/warble.rb"
|
286
|
-
puts "generating Warbler's config file"
|
287
|
-
includeDirs = []
|
288
|
-
Dir.mkdir('config') if not File.exists?('config')
|
289
|
-
aFile = File.new("config/warble.rb", "w+")
|
290
|
-
if aFile
|
291
|
-
includeDirs = FileList['*'].exclude do |entry|
|
292
|
-
entry if (not File.directory? entry) || (entry == 'spec')
|
293
|
-
end
|
294
|
-
configFile = "Warbler::Config.new do |config|\n" +
|
295
|
-
"config.dirs = %w(#{includeDirs.join(' ')})\n" +
|
296
|
-
"config.includes = FileList[\"./*\"]\n" +
|
297
|
-
"config.excludes = FileList[\"./*.war\",'spec']\nend"
|
298
|
-
aFile.write("#{configFile}")
|
299
|
-
aFile.close
|
300
|
-
else
|
301
|
-
puts "Unable to create config/warble.rb file!"
|
302
|
-
end
|
303
|
-
end
|
304
|
-
# build the executable WAR using the config/warble.rb file
|
305
|
-
ENV['BUNDLE_WITHOUT'] = ['development','test'].join(':')
|
306
|
-
system 'warble executable war'
|
307
|
-
else
|
308
|
-
puts "Cannot build WAR files outside of JRuby environment!"
|
309
|
-
end
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
task :default => ['rhoconnect:spec']
|
314
|
-
|
315
|
-
load File.join(File.dirname(__FILE__),'..','..','tasks','redis.rake')
|