rhoconnect 3.3.6 → 3.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +40 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +27 -25
- data/bench/benchapp/Gemfile +7 -27
- data/bench/benchapp/config.ru +9 -31
- data/bench/blobapp/Gemfile +7 -27
- data/bench/blobapp/config.ru +9 -29
- data/bench/lib/bench.rb +8 -1
- data/bench/lib/bench/test_data.rb +4 -1
- data/bench/scripts/blob_cud_script.rb +4 -0
- data/bench/scripts/cud_script.rb +7 -1
- data/bench/scripts/helpers.rb +1 -1
- data/bench/scripts/test_query_script.rb +20 -7
- data/bench/spec/bench_spec_helper.rb +3 -1
- data/bin/rhoconnect +22 -12
- data/commands/{commands/dtach_commands → dtach}/dtach_about.rb +0 -0
- data/commands/{commands/dtach_commands → dtach}/dtach_install.rb +0 -0
- data/commands/{commands/redis_commands → dtach}/redis_attach.rb +0 -0
- data/commands/execute.rb +14 -15
- data/commands/generators/update.rb +26 -0
- data/commands/{commands/redis_commands → redis}/redis_about.rb +0 -0
- data/commands/redis/redis_download.rb +13 -0
- data/commands/redis/redis_install.rb +26 -0
- data/commands/{commands/redis_commands → redis}/redis_make.rb +0 -0
- data/commands/{commands/redis_commands → redis}/redis_restart.rb +3 -2
- data/commands/{commands/redis_commands → redis}/redis_start.rb +0 -0
- data/commands/{commands/redis_commands → redis}/redis_startbg.rb +0 -0
- data/commands/{commands/redis_commands → redis}/redis_stop.rb +3 -2
- data/commands/{commands/rhoconnect → rhoconnect}/clean_start.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/config.rb +7 -2
- data/commands/{commands/rhoconnect → rhoconnect}/create_user.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/delete_device.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/delete_user.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/flushdb.rb +4 -4
- data/commands/{commands/rhoconnect → rhoconnect}/get_token.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/reset.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/reset_refresh.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/restart.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/secret.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/set_admin_password.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/spec.rb +0 -0
- data/commands/rhoconnect/start.rb +27 -0
- data/commands/{commands/rhoconnect → rhoconnect}/startbg.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/startdebug.rb +2 -2
- data/commands/{commands/rhoconnect → rhoconnect}/stop.rb +3 -4
- data/commands/{commands/rhoconnect → rhoconnect}/version.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect}/web.rb +0 -0
- data/commands/rhoconnect_attach/attach.rb +10 -0
- data/commands/rhoconnect_console/console.rb +16 -0
- data/commands/{commands/rhoconnect → rhoconnect_console}/console_helper.rb +0 -0
- data/commands/{commands/rhoconnect → rhoconnect_war}/war.rb +0 -0
- data/commands/{commands/redis_commands → utilities}/redis_runner.rb +22 -19
- data/commands/utilities/utilities.rb +6 -0
- data/doc/benchmarks.txt +2 -2
- data/doc/bulk-sync.txt +12 -1
- data/doc/client-java.txt +3 -3
- data/doc/client-objc.txt +1 -1
- data/doc/client.txt +5 -5
- data/doc/command-line.txt +80 -135
- data/doc/deploying.txt +119 -12
- data/doc/extending-rhoconnect-server.txt +1 -1
- data/doc/heroku-addon.txt +119 -23
- data/doc/install.txt +101 -39
- data/doc/java-plugin.txt +2 -2
- data/doc/licensing.txt +1 -1
- data/doc/plugin-intro.txt +3 -1
- data/doc/preparing-production.txt +4 -4
- data/doc/public/cli.txt +2 -2
- data/doc/push-backend-setup.txt +11 -1
- data/doc/push-client-setup.txt +72 -2
- data/doc/push-server-setup.txt +129 -8
- data/doc/rails-plugin.txt +245 -40
- data/doc/rest-api.txt +10 -6
- data/doc/rhoconnect-calculator.txt +237 -0
- data/doc/rhoconnect-redis-stack.txt +35 -0
- data/doc/session-and-configuration.txt +24 -0
- data/doc/settings.txt +51 -41
- data/doc/source-adapters.txt +45 -45
- data/doc/stats-middleware.txt +2 -2
- data/doc/supported-platforms.txt +6 -6
- data/doc/testing.txt +2 -2
- data/doc/tutorial.txt +63 -63
- data/examples/simple/Gemfile +7 -35
- data/examples/simple/config.ru +8 -26
- data/examples/simple/sources/product.rb +6 -6
- data/generators/rhoconnect.rb +5 -0
- data/generators/templates/application/Gemfile +7 -37
- data/generators/templates/application/Rakefile +8 -0
- data/generators/templates/application/config.ru +12 -31
- data/generators/templates/application/rcgemfile +44 -0
- data/generators/templates/application/settings/settings.yml +7 -5
- data/install.sh +4 -4
- data/installer/unix-like/create_texts.rb +7 -2
- data/installer/unix-like/rho_connect_install_constants.rb +2 -2
- data/installer/unix-like/rho_connect_install_installers.rb +1 -16
- data/lib/rhoconnect.rb +51 -38
- data/lib/rhoconnect/api/app/query.rb +4 -1
- data/lib/rhoconnect/api/app/search.rb +4 -1
- data/lib/rhoconnect/api/client/list_client_docs.rb +3 -1
- data/lib/rhoconnect/api/user/ping.rb +1 -5
- data/lib/rhoconnect/application/init.rb +43 -0
- data/lib/rhoconnect/async.rb +11 -6
- data/lib/rhoconnect/client_sync.rb +30 -37
- data/lib/rhoconnect/document.rb +4 -0
- data/lib/rhoconnect/graph_helper.rb +74 -56
- data/lib/rhoconnect/middleware/helpers.rb +4 -0
- data/lib/rhoconnect/ping.rb +1 -0
- data/lib/rhoconnect/ping/gcm.rb +58 -0
- data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +7 -1
- data/lib/rhoconnect/source.rb +70 -56
- data/lib/rhoconnect/source_sync.rb +33 -5
- data/lib/rhoconnect/store.rb +358 -110
- data/lib/rhoconnect/user.rb +8 -0
- data/lib/rhoconnect/utilities.rb +16 -14
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect/web-console/models/client.js +1 -1
- data/lib/rhoconnect/web-console/public/UNVR67bold.ttf +0 -0
- data/lib/rhoconnect/web-console/public/bootstrap.css +6 -0
- data/lib/rhoconnect/web-console/public/logo.png +0 -0
- data/lib/rhoconnect/web-console/server.rb +13 -11
- data/lib/rhoconnect/web-console/templates/index.erb +5 -5
- data/lib/rhoconnect/web-console/templates/jqplot.erb +1 -0
- data/lib/rhoconnect/web-console/views/doc.js +0 -4
- data/lib/rhoconnect/web-console/views/home.js +2 -1
- data/lib/rhoconnect/web-console/views/new_ping.js +11 -6
- data/lib/rhoconnect/web-console/views/stats.js +9 -5
- data/rhoconnect.gemspec +6 -4
- data/spec/api/app/fast_update_spec.rb +2 -2
- data/spec/api/source/get_source_params_spec.rb +1 -0
- data/spec/apps/rhotestapp/settings/settings.yml +5 -5
- data/spec/client_sync_spec.rb +3 -14
- data/spec/perf/perf_spec_helper.rb +11 -7
- data/spec/perf/store_perf_spec.rb +88 -11
- data/spec/ping/gcm_spec.rb +99 -0
- data/spec/server/server_spec.rb +7 -0
- data/spec/server/stats_spec.rb +9 -2
- data/spec/source_sync_spec.rb +29 -0
- data/spec/spec_helper.rb +40 -38
- data/spec/stats/record_spec.rb +18 -9
- data/spec/store_spec.rb +128 -19
- data/spec/testdata/10000-data.txt +0 -0
- data/spec/testdata/5-data.txt +0 -0
- data/spec/testdata/5000-data.txt +0 -0
- data/tasks/jasmine.rake +1 -0
- data/tasks/redis.rake +16 -13
- metadata +71 -39
- data/commands/commands/redis_commands/redis_download.rb +0 -33
- data/commands/commands/redis_commands/redis_install.rb +0 -26
- data/commands/commands/rhoconnect/attach.rb +0 -8
- data/commands/commands/rhoconnect/console.rb +0 -15
- data/commands/commands/rhoconnect/start.rb +0 -18
- data/commands/utilities/dtach_installed.rb +0 -10
@@ -18,8 +18,20 @@ Bench.config do |config|
|
|
18
18
|
# if this is not a distributed run - reset the app
|
19
19
|
if not Bench.sync_key
|
20
20
|
config.reset_app
|
21
|
-
@expected =
|
22
|
-
|
21
|
+
@expected = {}
|
22
|
+
data_to_create = @datasize
|
23
|
+
while (data_to_create > 0) do
|
24
|
+
nobjects = data_to_create > 1000 ? 1000 : data_to_create
|
25
|
+
data_page = Bench.get_test_data(nobjects, true)
|
26
|
+
config.set_server_state("test_db_storage:application:#{config.user_name}",data_page,true)
|
27
|
+
@expected.merge!(data_page)
|
28
|
+
data_to_create = data_to_create - nobjects
|
29
|
+
end
|
30
|
+
# also, simulate load for incremental syncs
|
31
|
+
@incr_expected = 25
|
32
|
+
incr_data_page = Bench.get_test_data(@incr_expected, true)
|
33
|
+
config.set_server_state("test_db_storage:application:nquser",incr_data_page)
|
34
|
+
|
23
35
|
#config.reset_refresh_time('RhoInternalBenchmarkAdapter', 0)
|
24
36
|
config.set_simulate_time('RhoInternalBenchmarkAdapter', Bench.simtime)
|
25
37
|
end
|
@@ -38,8 +50,9 @@ Bench.synchronize do |config|
|
|
38
50
|
end
|
39
51
|
|
40
52
|
Bench.test do |config,session|
|
53
|
+
username = SecureRandom.urlsafe_base64(10)
|
41
54
|
session.post "clientlogin", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/app/login", :content_type => :json do
|
42
|
-
{:login =>
|
55
|
+
{:login => username, :password => config.password}.to_json
|
43
56
|
end
|
44
57
|
session.post "clientcreate", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/clients"
|
45
58
|
client_id = JSON.parse(session.last_result.body)['client']['client_id']
|
@@ -58,15 +71,15 @@ Bench.test do |config,session|
|
|
58
71
|
{'X-RhoConnect-CLIENT-ID' => session.client_id} do
|
59
72
|
{'p_size' => pagesize}
|
60
73
|
end
|
61
|
-
token =
|
62
|
-
while (token != '') do
|
74
|
+
token = session.last_result.headers[:x_rhoconnect_page_token]
|
75
|
+
while (token and token != '') do
|
63
76
|
session.get "ack-cud",
|
64
77
|
"#{config.host}/app/#{Rhoconnect::API_VERSION}/RhoInternalBenchmarkAdapter",
|
65
78
|
{'X-RhoConnect-CLIENT-ID' => session.client_id} do
|
66
79
|
{'token' => token,
|
67
80
|
'p_size' => pagesize}
|
68
81
|
end
|
69
|
-
token =
|
82
|
+
token = session.last_result.headers[:x_rhoconnect_page_token]
|
70
83
|
session.last_result.verify_code(200)
|
71
84
|
end
|
72
85
|
|
@@ -90,7 +103,7 @@ Bench.test do |config,session|
|
|
90
103
|
session.post "push_deletes",
|
91
104
|
"#{config.host}/app/#{Rhoconnect::API_VERSION}/RhoInternalBenchmarkAdapter/push_deletes",
|
92
105
|
{'X-RhoConnect-API-TOKEN' => config.token, :content_type => :json} do
|
93
|
-
{:user_id =>
|
106
|
+
{:user_id => username,
|
94
107
|
:rebuild_md => false,
|
95
108
|
:objects => [obj_to_delete]
|
96
109
|
}.to_json
|
data/bin/rhoconnect
CHANGED
@@ -1,16 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
2
|
require 'rubygems'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
begin
|
4
|
+
if File.exists?(File.join(Dir.pwd,'Gemfile'))
|
5
|
+
require 'bundler'
|
6
|
+
Bundler.require
|
7
|
+
end
|
8
|
+
$:.unshift File.join(File.dirname(__FILE__),'..')
|
9
|
+
require 'templater'
|
10
|
+
require 'generators/rhoconnect'
|
11
|
+
require 'lib/rhoconnect'
|
12
|
+
require 'commands/execute'
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
Execute.start
|
15
|
+
rescue SystemExit => se
|
16
|
+
# This is normal
|
17
|
+
rescue Exception => e
|
18
|
+
if ARGV[0] == 'update' and e.class == Gem::LoadError
|
19
|
+
puts e.message
|
20
|
+
puts "\nUpdate your Gemfile to latest rhoconnect release and run 'rhoconnect update' again."
|
21
|
+
puts "See http://docs.rhomobile.com/rhoconnect/install#upgrading-an-existing-application about update details.\n\n"
|
22
|
+
else
|
23
|
+
puts "Run rhoconnect command error: #{e.inspect}"
|
24
|
+
end
|
25
|
+
end
|
15
26
|
|
16
|
-
Execute.start
|
File without changes
|
File without changes
|
File without changes
|
data/commands/execute.rb
CHANGED
@@ -10,29 +10,28 @@ $:.unshift File.join(File.dirname(__FILE__), '.')
|
|
10
10
|
$:.unshift File.join(File.dirname(__FILE__), '..')
|
11
11
|
require 'lib/rhoconnect/utilities'
|
12
12
|
require 'lib/rhoconnect'
|
13
|
+
require 'utilities/utilities'
|
14
|
+
require 'utilities/redis_runner'
|
13
15
|
|
14
16
|
include Utilities
|
15
17
|
|
16
|
-
TASK_DIRS = ['generators', 'commands', 'utilities']
|
17
|
-
|
18
18
|
class Execute < Thor
|
19
|
-
# Methods
|
20
19
|
no_tasks {
|
21
20
|
def self.define_task(&block)
|
22
|
-
Execute.class_eval
|
21
|
+
Execute.class_eval(&block)
|
23
22
|
end
|
24
23
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
|
25
|
+
tasks = [ 'generators', 'rhoconnect', 'redis' ]
|
26
|
+
unless windows?
|
27
|
+
tasks << 'dtach'
|
28
|
+
tasks << 'rhoconnect_attach' unless jruby?
|
29
|
+
end
|
30
|
+
tasks << if jruby? then "rhoconnect_war" else "rhoconnect_console" end
|
31
|
+
|
32
|
+
tasks.each do |dir|
|
33
|
+
Dir.glob(File.join(File.dirname(__FILE__), "#{dir}", "*.rb")) do |file|
|
34
|
+
require file
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "update", "Updates an existing application to the latest rhoconnect release."
|
3
|
+
def update
|
4
|
+
Bundler.with_clean_env do
|
5
|
+
`bundle install`
|
6
|
+
end
|
7
|
+
|
8
|
+
path_to_tempate = File.expand_path(File.join(File.dirname(__FILE__), '..','..', 'generators', 'templates', 'application'))
|
9
|
+
unless File.exist?('.rcgemfile')
|
10
|
+
require 'erb'
|
11
|
+
File.open('Gemfile.new', 'w') do |f|
|
12
|
+
gem_version = Rhoconnect::VERSION
|
13
|
+
template = ERB.new(IO.read(File.join(path_to_tempate, 'Gemfile')))
|
14
|
+
f << template.result(binding)
|
15
|
+
end
|
16
|
+
puts "The new Gemfile for rhoconnect version '#{Rhoconnect::VERSION}' is saved as Gemfile.new"
|
17
|
+
end
|
18
|
+
|
19
|
+
FileUtils.copy(File.join(path_to_tempate, 'rcgemfile'), '.rcgemfile')
|
20
|
+
|
21
|
+
Bundler.with_clean_env do
|
22
|
+
`bundle install`
|
23
|
+
end
|
24
|
+
puts "\nSee http://docs.rhomobile.com/rhoconnect/install#upgrading-an-existing-application about update details.\n\n"
|
25
|
+
end
|
26
|
+
end
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
REDIS_RELEASE = "2.4.10"
|
2
|
+
Execute.define_task do
|
3
|
+
desc "redis-download", "Download redis release #{REDIS_RELEASE}"
|
4
|
+
def redis_download
|
5
|
+
unless windows?
|
6
|
+
system 'rm -rf /tmp/redis/' if File.exists?("#{RedisRunner.redisdir}")
|
7
|
+
system 'git clone git://github.com/antirez/redis.git /tmp/redis -n'
|
8
|
+
system "cd #{RedisRunner.redisdir} && git reset --hard && git checkout #{REDIS_RELEASE}"
|
9
|
+
else
|
10
|
+
puts "Not implemented on Windows"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "redis-install", 'Install the latest verison of Redis from Github (requires git, duh)'
|
3
|
+
def redis_install
|
4
|
+
invoke :redis_about
|
5
|
+
invoke :redis_download
|
6
|
+
invoke :redis_make
|
7
|
+
unless windows?
|
8
|
+
ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "#{RedisRunner.prefix}bin"
|
9
|
+
|
10
|
+
mk_bin_dir(bin_dir)
|
11
|
+
|
12
|
+
%w(redis-benchmark redis-cli redis-server).each do |bin|
|
13
|
+
system "cp /tmp/redis/src/#{bin} #{bin_dir}"
|
14
|
+
end #do
|
15
|
+
|
16
|
+
puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}"
|
17
|
+
|
18
|
+
ENV['PREFIX'] and conf_dir = "#{ENV['PREFIX']}/etc" or conf_dir = "#{RedisRunner.prefix}etc"
|
19
|
+
unless File.exists?("#{conf_dir}/redis.conf")
|
20
|
+
system "mkdir #{conf_dir}" unless File.exists?("#{conf_dir}")
|
21
|
+
system "cp /tmp/redis/redis.conf #{conf_dir}/redis.conf"
|
22
|
+
puts "Installed redis.conf to #{conf_dir} \n You should look at this file!"
|
23
|
+
end #unless
|
24
|
+
end #unless
|
25
|
+
end #redis_install
|
26
|
+
end #do
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -3,6 +3,7 @@ Execute.define_task do
|
|
3
3
|
def config
|
4
4
|
$settings = load_settings(File.join('settings','settings.yml'))
|
5
5
|
$env = (ENV['RHO_ENV'] || ENV['RACK_ENV'] || :development).to_sym
|
6
|
+
|
6
7
|
uri = URI.parse($settings[$env][:syncserver])
|
7
8
|
$url = "#{uri.scheme}://#{uri.host}"
|
8
9
|
$url = "#{$url}:#{uri.port}" if uri.port && uri.port != 80
|
@@ -11,5 +12,9 @@ Execute.define_task do
|
|
11
12
|
$appname = $settings[$env][:syncserver].split('/').last
|
12
13
|
$token_file = File.join(ENV['HOME'],'.rhoconnect_token')
|
13
14
|
$token = File.read($token_file) if File.exist?($token_file)
|
14
|
-
|
15
|
-
|
15
|
+
# Redis options
|
16
|
+
redis_server = $settings[$env][:redis]
|
17
|
+
host, port, db, password = redis_server.split(':')
|
18
|
+
$redis_options = { :host => host, :port => port, :db => db, :password => password }
|
19
|
+
end
|
20
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -5,10 +5,10 @@ Execute.define_task do
|
|
5
5
|
puts "*** WARNING: THIS WILL REMOVE ALL DATA FROM YOUR REDIS STORE ***"
|
6
6
|
confirm = ask "Are you sure (please answer yes/no)? "
|
7
7
|
if confirm == 'yes'
|
8
|
-
|
8
|
+
RedisRunner.flushdb
|
9
9
|
puts "Database flushed..."
|
10
10
|
else
|
11
11
|
puts "Aborted..."
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "start", "Start rhoconnect server"
|
3
|
+
def start
|
4
|
+
invoke :config
|
5
|
+
unless RedisRunner.running?
|
6
|
+
redis_config = "#{$redis_options[:host]}:#{$redis_options[:port]}"
|
7
|
+
puts "Redis is not running on #{redis_config}. Please start it by running 'rhoconnect redis-start' command."
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
command = (jruby?) ? trinidad? : (thin? || mongrel? || report_missing_server)
|
11
|
+
if windows?
|
12
|
+
puts 'Starting rhoconnect...'
|
13
|
+
system "#{command} config.ru -P #{rhoconnect_pid}"
|
14
|
+
elsif jruby?
|
15
|
+
puts 'Starting rhoconnect in jruby environment...'
|
16
|
+
system "#{command}"
|
17
|
+
else
|
18
|
+
if dtach_installed?
|
19
|
+
puts 'Detach with Ctrl+\ Re-attach with rhoconnect attach'
|
20
|
+
sleep 2
|
21
|
+
cmd "dtach -A #{rhoconnect_socket} #{command} config.ru -P #{rhoconnect_pid}"
|
22
|
+
else
|
23
|
+
cmd "#{command} config.ru -P #{rhoconnect_pid}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
File without changes
|
@@ -11,8 +11,8 @@ Execute.define_task do
|
|
11
11
|
cmd = (jruby?) ? trinidad? : (thin? || mongrel? || report_missing_server)
|
12
12
|
ENV['DEBUG'] = 'yes'
|
13
13
|
require 'win32/process' if windows?
|
14
|
-
|
15
|
-
p1 = Process.fork {
|
14
|
+
|
15
|
+
p1 = Process.fork {
|
16
16
|
if windows?
|
17
17
|
puts 'Starting rhoconnect ...'
|
18
18
|
system "#{cmd} config.ru -P #{rhoconnect_pid}"
|
@@ -1,11 +1,10 @@
|
|
1
1
|
Execute.define_task do
|
2
2
|
desc "stop", "Stop rhoconnect server"
|
3
3
|
def stop
|
4
|
-
invoke :dtach_installed
|
5
4
|
if windows?
|
6
5
|
File.delete "#{rhoconnect_pid}" if system("FOR /F %A in (#{rhoconnect_pid}) do taskkill /F /PID %A")
|
7
6
|
else
|
8
7
|
cmd "cat #{rhoconnect_pid} | xargs kill -3"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "console [environment]", "run rhoconnect console"
|
3
|
+
def console(environment=nil)
|
4
|
+
ENV['RACK_ENV'] = environment || 'development'
|
5
|
+
application_file = ruby19? ? './application' : 'application'
|
6
|
+
invoke :config
|
7
|
+
if RedisRunner.running?
|
8
|
+
system "irb -rubygems -r #{File.join(File.dirname(__FILE__),'console_helper')} " +
|
9
|
+
"-r #{File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rhoconnect') } " +
|
10
|
+
"-r #{application_file}"
|
11
|
+
else
|
12
|
+
redis_config = "#{$redis_options[:host]}:#{$redis_options[:port]}"
|
13
|
+
puts "Redis is not running on #{redis_config}. Please start it by running 'rhoconnect redis-start' command."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
File without changes
|
@@ -1,7 +1,4 @@
|
|
1
|
-
REDIS_RELEASE = "2.4.10"
|
2
|
-
|
3
1
|
class RedisRunner
|
4
|
-
|
5
2
|
def self.prefix
|
6
3
|
"/usr/local/"
|
7
4
|
end
|
@@ -13,9 +10,7 @@ class RedisRunner
|
|
13
10
|
def self.redisconfdir
|
14
11
|
server_dir = File.dirname(`which redis-server`)
|
15
12
|
conf_file = "#{RedisRunner.prefix}etc/redis.conf"
|
16
|
-
unless File.exists? conf_file
|
17
|
-
conf_file = "#{server_dir}/redis.conf"
|
18
|
-
end
|
13
|
+
conf_file = "#{server_dir}/redis.conf" unless File.exists? conf_file
|
19
14
|
conf_file
|
20
15
|
end
|
21
16
|
|
@@ -23,16 +18,18 @@ class RedisRunner
|
|
23
18
|
'/tmp/redis.dtach'
|
24
19
|
end
|
25
20
|
|
26
|
-
# Just check for existance of dtach socket
|
27
21
|
def self.running?
|
28
|
-
|
22
|
+
$redis_options ||= {}
|
23
|
+
Redis.new($redis_options).ping == 'PONG'
|
24
|
+
rescue
|
25
|
+
false
|
29
26
|
end
|
30
27
|
|
31
28
|
def self.start
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
if windows?
|
30
|
+
puts "Starting redis in a new window..."
|
31
|
+
system "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
|
32
|
+
"redis-server not installed on your path, please install redis."
|
36
33
|
elsif defined?(JRUBY_VERSION)
|
37
34
|
puts "Starting redis ..."
|
38
35
|
system "redis-server #{redisconfdir}"
|
@@ -43,13 +40,13 @@ class RedisRunner
|
|
43
40
|
system command
|
44
41
|
end
|
45
42
|
end
|
46
|
-
|
43
|
+
|
47
44
|
# this function is used with Rhostudio where there is no terminal
|
48
45
|
def self.startbg
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
if windows?
|
47
|
+
puts "Starting redis in a new window..."
|
48
|
+
system "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
|
49
|
+
"redis-server not installed on your path, please install redis."
|
53
50
|
else
|
54
51
|
puts "Starting redis ..."
|
55
52
|
system "redis-server #{redisconfdir} &"
|
@@ -61,7 +58,13 @@ class RedisRunner
|
|
61
58
|
end
|
62
59
|
|
63
60
|
def self.stop
|
64
|
-
|
61
|
+
$redis_options ||= {}
|
62
|
+
Redis.new($redis_options).shutdown rescue nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.flushdb
|
66
|
+
$redis_options ||= {}
|
67
|
+
Redis.new($redis_options).flushdb rescue nil
|
65
68
|
end
|
66
69
|
|
67
|
-
end
|
70
|
+
end
|