rhoconnect 3.3.6 → 3.4.2

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.
Files changed (152) hide show
  1. data/CHANGELOG.md +40 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +27 -25
  4. data/bench/benchapp/Gemfile +7 -27
  5. data/bench/benchapp/config.ru +9 -31
  6. data/bench/blobapp/Gemfile +7 -27
  7. data/bench/blobapp/config.ru +9 -29
  8. data/bench/lib/bench.rb +8 -1
  9. data/bench/lib/bench/test_data.rb +4 -1
  10. data/bench/scripts/blob_cud_script.rb +4 -0
  11. data/bench/scripts/cud_script.rb +7 -1
  12. data/bench/scripts/helpers.rb +1 -1
  13. data/bench/scripts/test_query_script.rb +20 -7
  14. data/bench/spec/bench_spec_helper.rb +3 -1
  15. data/bin/rhoconnect +22 -12
  16. data/commands/{commands/dtach_commands → dtach}/dtach_about.rb +0 -0
  17. data/commands/{commands/dtach_commands → dtach}/dtach_install.rb +0 -0
  18. data/commands/{commands/redis_commands → dtach}/redis_attach.rb +0 -0
  19. data/commands/execute.rb +14 -15
  20. data/commands/generators/update.rb +26 -0
  21. data/commands/{commands/redis_commands → redis}/redis_about.rb +0 -0
  22. data/commands/redis/redis_download.rb +13 -0
  23. data/commands/redis/redis_install.rb +26 -0
  24. data/commands/{commands/redis_commands → redis}/redis_make.rb +0 -0
  25. data/commands/{commands/redis_commands → redis}/redis_restart.rb +3 -2
  26. data/commands/{commands/redis_commands → redis}/redis_start.rb +0 -0
  27. data/commands/{commands/redis_commands → redis}/redis_startbg.rb +0 -0
  28. data/commands/{commands/redis_commands → redis}/redis_stop.rb +3 -2
  29. data/commands/{commands/rhoconnect → rhoconnect}/clean_start.rb +0 -0
  30. data/commands/{commands/rhoconnect → rhoconnect}/config.rb +7 -2
  31. data/commands/{commands/rhoconnect → rhoconnect}/create_user.rb +0 -0
  32. data/commands/{commands/rhoconnect → rhoconnect}/delete_device.rb +0 -0
  33. data/commands/{commands/rhoconnect → rhoconnect}/delete_user.rb +0 -0
  34. data/commands/{commands/rhoconnect → rhoconnect}/flushdb.rb +4 -4
  35. data/commands/{commands/rhoconnect → rhoconnect}/get_token.rb +0 -0
  36. data/commands/{commands/rhoconnect → rhoconnect}/reset.rb +0 -0
  37. data/commands/{commands/rhoconnect → rhoconnect}/reset_refresh.rb +0 -0
  38. data/commands/{commands/rhoconnect → rhoconnect}/restart.rb +0 -0
  39. data/commands/{commands/rhoconnect → rhoconnect}/secret.rb +0 -0
  40. data/commands/{commands/rhoconnect → rhoconnect}/set_admin_password.rb +0 -0
  41. data/commands/{commands/rhoconnect → rhoconnect}/spec.rb +0 -0
  42. data/commands/rhoconnect/start.rb +27 -0
  43. data/commands/{commands/rhoconnect → rhoconnect}/startbg.rb +0 -0
  44. data/commands/{commands/rhoconnect → rhoconnect}/startdebug.rb +2 -2
  45. data/commands/{commands/rhoconnect → rhoconnect}/stop.rb +3 -4
  46. data/commands/{commands/rhoconnect → rhoconnect}/version.rb +0 -0
  47. data/commands/{commands/rhoconnect → rhoconnect}/web.rb +0 -0
  48. data/commands/rhoconnect_attach/attach.rb +10 -0
  49. data/commands/rhoconnect_console/console.rb +16 -0
  50. data/commands/{commands/rhoconnect → rhoconnect_console}/console_helper.rb +0 -0
  51. data/commands/{commands/rhoconnect → rhoconnect_war}/war.rb +0 -0
  52. data/commands/{commands/redis_commands → utilities}/redis_runner.rb +22 -19
  53. data/commands/utilities/utilities.rb +6 -0
  54. data/doc/benchmarks.txt +2 -2
  55. data/doc/bulk-sync.txt +12 -1
  56. data/doc/client-java.txt +3 -3
  57. data/doc/client-objc.txt +1 -1
  58. data/doc/client.txt +5 -5
  59. data/doc/command-line.txt +80 -135
  60. data/doc/deploying.txt +119 -12
  61. data/doc/extending-rhoconnect-server.txt +1 -1
  62. data/doc/heroku-addon.txt +119 -23
  63. data/doc/install.txt +101 -39
  64. data/doc/java-plugin.txt +2 -2
  65. data/doc/licensing.txt +1 -1
  66. data/doc/plugin-intro.txt +3 -1
  67. data/doc/preparing-production.txt +4 -4
  68. data/doc/public/cli.txt +2 -2
  69. data/doc/push-backend-setup.txt +11 -1
  70. data/doc/push-client-setup.txt +72 -2
  71. data/doc/push-server-setup.txt +129 -8
  72. data/doc/rails-plugin.txt +245 -40
  73. data/doc/rest-api.txt +10 -6
  74. data/doc/rhoconnect-calculator.txt +237 -0
  75. data/doc/rhoconnect-redis-stack.txt +35 -0
  76. data/doc/session-and-configuration.txt +24 -0
  77. data/doc/settings.txt +51 -41
  78. data/doc/source-adapters.txt +45 -45
  79. data/doc/stats-middleware.txt +2 -2
  80. data/doc/supported-platforms.txt +6 -6
  81. data/doc/testing.txt +2 -2
  82. data/doc/tutorial.txt +63 -63
  83. data/examples/simple/Gemfile +7 -35
  84. data/examples/simple/config.ru +8 -26
  85. data/examples/simple/sources/product.rb +6 -6
  86. data/generators/rhoconnect.rb +5 -0
  87. data/generators/templates/application/Gemfile +7 -37
  88. data/generators/templates/application/Rakefile +8 -0
  89. data/generators/templates/application/config.ru +12 -31
  90. data/generators/templates/application/rcgemfile +44 -0
  91. data/generators/templates/application/settings/settings.yml +7 -5
  92. data/install.sh +4 -4
  93. data/installer/unix-like/create_texts.rb +7 -2
  94. data/installer/unix-like/rho_connect_install_constants.rb +2 -2
  95. data/installer/unix-like/rho_connect_install_installers.rb +1 -16
  96. data/lib/rhoconnect.rb +51 -38
  97. data/lib/rhoconnect/api/app/query.rb +4 -1
  98. data/lib/rhoconnect/api/app/search.rb +4 -1
  99. data/lib/rhoconnect/api/client/list_client_docs.rb +3 -1
  100. data/lib/rhoconnect/api/user/ping.rb +1 -5
  101. data/lib/rhoconnect/application/init.rb +43 -0
  102. data/lib/rhoconnect/async.rb +11 -6
  103. data/lib/rhoconnect/client_sync.rb +30 -37
  104. data/lib/rhoconnect/document.rb +4 -0
  105. data/lib/rhoconnect/graph_helper.rb +74 -56
  106. data/lib/rhoconnect/middleware/helpers.rb +4 -0
  107. data/lib/rhoconnect/ping.rb +1 -0
  108. data/lib/rhoconnect/ping/gcm.rb +58 -0
  109. data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +7 -1
  110. data/lib/rhoconnect/source.rb +70 -56
  111. data/lib/rhoconnect/source_sync.rb +33 -5
  112. data/lib/rhoconnect/store.rb +358 -110
  113. data/lib/rhoconnect/user.rb +8 -0
  114. data/lib/rhoconnect/utilities.rb +16 -14
  115. data/lib/rhoconnect/version.rb +1 -1
  116. data/lib/rhoconnect/web-console/models/client.js +1 -1
  117. data/lib/rhoconnect/web-console/public/UNVR67bold.ttf +0 -0
  118. data/lib/rhoconnect/web-console/public/bootstrap.css +6 -0
  119. data/lib/rhoconnect/web-console/public/logo.png +0 -0
  120. data/lib/rhoconnect/web-console/server.rb +13 -11
  121. data/lib/rhoconnect/web-console/templates/index.erb +5 -5
  122. data/lib/rhoconnect/web-console/templates/jqplot.erb +1 -0
  123. data/lib/rhoconnect/web-console/views/doc.js +0 -4
  124. data/lib/rhoconnect/web-console/views/home.js +2 -1
  125. data/lib/rhoconnect/web-console/views/new_ping.js +11 -6
  126. data/lib/rhoconnect/web-console/views/stats.js +9 -5
  127. data/rhoconnect.gemspec +6 -4
  128. data/spec/api/app/fast_update_spec.rb +2 -2
  129. data/spec/api/source/get_source_params_spec.rb +1 -0
  130. data/spec/apps/rhotestapp/settings/settings.yml +5 -5
  131. data/spec/client_sync_spec.rb +3 -14
  132. data/spec/perf/perf_spec_helper.rb +11 -7
  133. data/spec/perf/store_perf_spec.rb +88 -11
  134. data/spec/ping/gcm_spec.rb +99 -0
  135. data/spec/server/server_spec.rb +7 -0
  136. data/spec/server/stats_spec.rb +9 -2
  137. data/spec/source_sync_spec.rb +29 -0
  138. data/spec/spec_helper.rb +40 -38
  139. data/spec/stats/record_spec.rb +18 -9
  140. data/spec/store_spec.rb +128 -19
  141. data/spec/testdata/10000-data.txt +0 -0
  142. data/spec/testdata/5-data.txt +0 -0
  143. data/spec/testdata/5000-data.txt +0 -0
  144. data/tasks/jasmine.rake +1 -0
  145. data/tasks/redis.rake +16 -13
  146. metadata +71 -39
  147. data/commands/commands/redis_commands/redis_download.rb +0 -33
  148. data/commands/commands/redis_commands/redis_install.rb +0 -26
  149. data/commands/commands/rhoconnect/attach.rb +0 -8
  150. data/commands/commands/rhoconnect/console.rb +0 -15
  151. data/commands/commands/rhoconnect/start.rb +0 -18
  152. 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 = Bench.get_test_data(@datasize)
22
- config.set_server_state("test_db_storage:application:#{config.user_name}",@expected)
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 => config.user_name, :password => config.password}.to_json
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 = JSON.parse(session.last_result.body)[1]['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 = JSON.parse(session.last_result.body)[1]['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 => config.user_name,
106
+ {:user_id => username,
94
107
  :rebuild_md => false,
95
108
  :objects => [obj_to_delete]
96
109
  }.to_json
@@ -6,7 +6,9 @@ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
6
6
 
7
7
  if RUBY_VERSION =~ /1.9/ || defined?(JRUBY_VERSION)
8
8
  require 'simplecov'
9
- SimpleCov.start
9
+ SimpleCov.start do
10
+ add_filter '/spec/'
11
+ end
10
12
  end
11
13
 
12
14
  require 'bench/logging'
data/bin/rhoconnect CHANGED
@@ -1,16 +1,26 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'rubygems'
4
- if File.exists?(File.join(Dir.pwd,'Gemfile'))
5
- require 'bundler'
6
- Bundler.require
7
- end
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
- $:.unshift File.join(File.dirname(__FILE__),'..')
10
-
11
- require 'templater'
12
- require 'generators/rhoconnect'
13
- require 'lib/rhoconnect'
14
- require 'commands/execute'
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
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 &block
21
+ Execute.class_eval(&block)
23
22
  end
24
23
  }
25
- # Require all tasks defined in the tasks directories
26
- TASK_DIRS.each do |dir|
27
- Find.find("#{File.expand_path(File.dirname(__FILE__))}/#{dir}") do |path|
28
- if !File.directory? path and File.extname(path) == '.rb'
29
- if File.basename(path, '.rb') == 'spec'
30
- rspec_avail = File.exists?(File.join(Dir.pwd,'Gemfile')) && Bundler.load.specs.find{|s| s.name == 'rspec' }
31
- # Drop task 'spec' if gem 'rspec' is not in the current bundle.
32
- next unless rspec_avail
33
- end
34
- require path
35
- end
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
@@ -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
@@ -1,7 +1,8 @@
1
1
  Execute.define_task do
2
2
  desc "redis-restart", 'Restart redis'
3
3
  def redis_restart
4
+ invoke :config
4
5
  RedisRunner.stop
5
6
  RedisRunner.start
6
- end #redis_restart
7
- end #do
7
+ end
8
+ end
@@ -1,6 +1,7 @@
1
1
  Execute.define_task do
2
2
  desc "redis-stop", 'Stop redis'
3
3
  def redis_stop
4
+ invoke :config
4
5
  RedisRunner.stop
5
- end #redis_stop
6
- end #do
6
+ end
7
+ end
@@ -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
- end #config
15
- end #do
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
@@ -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
- Redis.new.flushdb
8
+ RedisRunner.flushdb
9
9
  puts "Database flushed..."
10
10
  else
11
11
  puts "Aborted..."
12
- end #if
13
- end #flushdb
14
- end #do
12
+ end
13
+ end
14
+ end
@@ -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
@@ -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 #if
10
- end #stop
11
- end #do
8
+ end
9
+ end
10
+ end
File without changes
@@ -0,0 +1,10 @@
1
+ Execute.define_task do
2
+ desc "attach", "Attach to rhoconnect console"
3
+ def attach
4
+ if dtach_installed?
5
+ system "dtach -a #{rhoconnect_socket}"
6
+ else
7
+ "Cannot attach to rhoconnect console. 'dtach' program is not installed."
8
+ end
9
+ end
10
+ end
@@ -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
@@ -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
- File.exists? dtach_socket
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
- if windows?
33
- puts "Starting redis in a new window..."
34
- system "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
35
- "redis-server not installed on your path, please run 'rhoconnect redis-install' first."
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
- if windows?
50
- puts "Starting redis in a new window..."
51
- system "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
52
- "redis-server not installed on your path, please run 'rhoconnect redis-install' first."
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
- Redis.new.shutdown rescue nil
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 #RedisRunner
70
+ end