rhoconnect 3.3.6 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -3,39 +3,11 @@ source 'http://rubygems.org'
3
3
  # load rhoconnect from relative path
4
4
  gem 'rhoconnect', :path => '../../'
5
5
 
6
- # Helps with some of the limitations of green threads, not needed in ruby 1.9.x
7
- gem 'SystemTimer', '~> 1.2.3', :platforms => :ruby_18
8
- gem 'win32-process', :platforms => [:mswin, :mingw]
9
-
10
- gem 'rack-parser', :require => 'rack/parser'
11
-
12
- # for Async, Eventful execution
13
- platforms :ruby_19 do
14
- gem 'rack-fiber_pool'
15
- gem 'async-rack'
16
- end
17
-
18
- platforms :jruby do
19
- gem 'jdbc-sqlite3', ">= 3.7.2"
20
- gem 'dbi', ">= 0.4.5"
21
- gem 'dbd-jdbc', ">= 0.1.4"
22
- gem 'jruby-openssl', ">= 0.7.4"
23
- gem 'trinidad'
24
- gem 'warbler'
25
- end
26
-
27
- #gem 'sqlite3', ">= 1.3.3", :platforms => [:ruby, :mswin, :mingw]
28
-
29
- group :development do
30
- # FIXME: At this moment (01/10/2012) only pre release of 'eventmachine' is working on Windows
31
- gem 'eventmachine', '~> 1.0.0.beta', :platforms => [:mswin, :mingw]
32
- # By default to run application thin web server is used
33
- gem 'thin', :platforms => [:ruby, :mswin, :mingw]
34
- gem 'rhomobile-debug', ">= 1.0.2"
35
- end
36
-
37
- group :test do
38
- gem 'rack-test', '>= 0.5.3', :require => "rack/test"
39
- gem 'rspec', '~> 2.6.0'
40
- gem 'rhomobile-debug', ">= 1.0.2"
6
+ gemfile_path = File.join(File.dirname(__FILE__), '..', '..', 'generators','templates', 'application', ".rcgemfile")
7
+ begin
8
+ eval(IO.read(gemfile_path))
9
+ rescue Exception => e
10
+ puts "ERROR: Couldn't find RhoConnect .rcgemfile"
11
+ puts e.message
12
+ exit 1
41
13
  end
@@ -1,35 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'bundler'
4
- Bundler.require
2
+ require 'rhoconnect/application/init'
5
3
 
6
- ROOT_PATH = File.expand_path(File.dirname(__FILE__))
7
-
8
- if ENV['DEBUG'] == 'yes'
9
- ENV['APP_TYPE'] = 'rhosync'
10
- ENV['ROOT_PATH'] = ROOT_PATH
11
- require 'debugger'
12
- end
13
-
14
- require 'rhoconnect/server'
15
- require 'rhoconnect/web-console/server'
16
- require 'resque/server'
4
+ # secret is generated along with the app
5
+ Rhoconnect::Server.set :secret, '3ddaa72a36466bae3fc5e54c09324db50cfc30588d8dee1a2700e61195bdbbb5eeb65da2a184d274ce644b20b0e986046c2447730c85555ce18a4eb2fce7ebf5'
17
6
 
18
- # Rhoconnect server flags
19
- Rhoconnect::Server.disable :run
7
+ # !!! Add your custom initializers and overrides here !!!
8
+ # For example, uncomment the following line to enable Stats
20
9
  Rhoconnect::Server.enable :stats
21
- Rhoconnect::Server.disable :clean_trace
22
- Rhoconnect::Server.enable :raise_errors
23
- Rhoconnect::Server.set :secret, '3ddaa72a36466bae3fc5e54c09324db50cfc30588d8dee1a2700e61195bdbbb5eeb65da2a184d274ce644b20b0e986046c2447730c85555ce18a4eb2fce7ebf5'
24
- Rhoconnect::Server.set :root, ROOT_PATH
25
- Rhoconnect::Server.use Rack::Static, :urls => ['/data'], :root => Rhoconnect::Server.root
26
10
 
27
- # Load our rhoconnect application
11
+ # Load RhoConnect application
28
12
  require './application'
29
13
  require './my_server'
30
14
 
31
15
  # Setup the url map
32
- run Rack::URLMap.new \
33
- '/' => MyServer.new,
34
- '/resque' => Resque::Server.new, # If you don't want resque frontend, disable it here
35
- '/console' => RhoconnectConsole::Server.new # If you don't want rhoconnect frontend, disable it here
16
+ # run RhoConnect Application
17
+ run Rhoconnect.app
@@ -3,24 +3,24 @@ require 'rest_client'
3
3
 
4
4
  class Product < SourceAdapter
5
5
  def initialize(source)
6
- @base = 'http://rhostore.heroku.com/products'
6
+ @base = 'http://rhostore.herokuapp.com/products'
7
7
  super(source)
8
8
  end
9
-
9
+
10
10
  def query
11
11
  parsed=JSON.parse(RestClient.get("#{@base}.json").body)
12
12
 
13
13
  @result={}
14
14
  if parsed
15
- parsed.each do |item|
15
+ parsed.each do |item|
16
16
  key = item["product"]["id"].to_s
17
17
  @result[key]=item["product"]
18
18
  end
19
- end
19
+ end
20
20
  end
21
21
 
22
22
  def sync
23
- # Manipulate @result before it is saved, or save it
23
+ # Manipulate @result before it is saved, or save it
24
24
  # yourself using the Rhoconnect::Store interface.
25
25
  # By default, super is called below which simply saves @result
26
26
  super
@@ -28,7 +28,7 @@ class Product < SourceAdapter
28
28
 
29
29
  def create(create_hash)
30
30
  # TODO: Create a new record in your backend data source
31
- # If your rhodes rhom object contains image/binary data
31
+ # If your rhodes rhom object contains image/binary data
32
32
  # (has the image_uri attribute), then a blob will be provided
33
33
  raise "Please provide some code to create a single record in the backend data source using the create_hash"
34
34
  end
@@ -76,6 +76,11 @@ module Rhoconnect
76
76
  template.destination = "#{name}/Gemfile"
77
77
  end
78
78
 
79
+ template :gemfile_app do |template|
80
+ template.source = 'rcgemfile'
81
+ template.destination = "#{name}/.rcgemfile"
82
+ end
83
+
79
84
  template :spec_helper do |template|
80
85
  template.source = 'spec/spec_helper.rb'
81
86
  template.destination = "#{name}/spec/spec_helper.rb"
@@ -1,43 +1,13 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'rhoconnect', '<%=gem_version%>'
4
+ gemfile_path = File.join(File.dirname(__FILE__), ".rcgemfile")
4
5
 
5
- # Helps with some of the limitations of green threads, not needed in ruby 1.9.x
6
- gem 'SystemTimer', '~> 1.2.3', :platforms => :ruby_18
7
- gem 'win32-process', :platforms => [:mswin, :mingw]
8
-
9
- # use thin and eventmachine everywhere except JRuby
10
- platforms :ruby, :ruby_19, :mingw, :mingw_19 do
11
- gem "eventmachine", "~> 1.0.0.beta"
12
- # using thin by default
13
- gem 'thin'
14
- end
15
-
16
- # for async framework
17
- # for Async, Eventful execution
18
- platforms :ruby_19, :mingw_19 do
19
- gem 'rack-fiber_pool'
20
- gem 'async-rack'
21
- end
22
-
23
- platforms :jruby do
24
- gem 'jdbc-sqlite3', ">= 3.7.2"
25
- gem 'dbi', ">= 0.4.5"
26
- gem 'dbd-jdbc', ">= 0.1.4"
27
- gem 'jruby-openssl', ">= 0.7.4"
28
- gem 'trinidad'
29
- gem 'warbler'
6
+ begin
7
+ eval(IO.read(gemfile_path))
8
+ rescue Exception => e
9
+ puts "ERROR: Couldn't read RhoConnect .rcgemfile"
10
+ exit 1
30
11
  end
31
12
 
32
- # uncomment the line below to use bulk sync: http://docs.rhomobile.com/rhoconnect/bulk-sync
33
- # gem 'sqlite3', ">= 1.3.3", :platforms => [:ruby, :mswin, :mingw]
34
-
35
- group :development do
36
- gem 'rhomobile-debug', ">= 1.0.2"
37
- end
38
-
39
- group :test do
40
- gem 'rspec', '~> 2.10.0'
41
- gem 'rack-test', '>= 0.5.3', :require => "rack/test"
42
- gem 'rhomobile-debug', ">= 1.0.2"
43
- end
13
+ # Add your application specific gems after this line ...
@@ -4,6 +4,14 @@ require 'rhoconnect/tasks'
4
4
  require 'rhoconnect'
5
5
  require 'resque/tasks'
6
6
 
7
+ ROOT_PATH = File.expand_path(File.dirname(__FILE__))
8
+
7
9
  task 'resque:setup' do
10
+ # The number of redis connections you want a job to have
11
+ Rhoconnect.connection_pool_size = 1
8
12
  require './application'
13
+
14
+ Resque.after_fork do
15
+ Store.db.client.reconnect
16
+ end
9
17
  end
@@ -1,38 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'bundler'
4
- Bundler.require
2
+ require 'rhoconnect/application/init'
5
3
 
6
- ROOT_PATH = File.expand_path(File.dirname(__FILE__))
7
-
8
- if ENV['DEBUG'] == 'yes'
9
- ENV['APP_TYPE'] = 'rhosync'
10
- ENV['ROOT_PATH'] = ROOT_PATH
11
- require 'debugger'
12
- end
13
-
14
- require 'rhoconnect/server'
15
- require 'rhoconnect/web-console/server'
16
- require 'resque/server'
4
+ # secret is generated along with the app
5
+ Rhoconnect::Server.set :secret, '<%= @secret %>'
17
6
 
18
- # Rhoconnect server flags
7
+ # !!! Add your custom initializers and overrides here !!!
8
+ # For example, uncomment the following line to enable Stats
19
9
  #Rhoconnect::Server.enable :stats
20
- Rhoconnect::Server.disable :run
21
- Rhoconnect::Server.disable :clean_trace
22
- Rhoconnect::Server.enable :raise_errors
23
- Rhoconnect::Server.set :secret, '<%= @secret %>'
24
- Rhoconnect::Server.set :root, ROOT_PATH
25
- Rhoconnect::Server.use Rack::Static, :urls => ['/data'], :root => Rhoconnect::Server.root
26
- # disable Async mode if Debugger is used
27
- if ENV['DEBUG'] == 'yes'
28
- Rhoconnect::Server.set :use_async_model, false
29
- end
10
+ # uncomment the following line to disable Resque Front-end console
11
+ #Rhoconnect.disable_resque_console = true
12
+ # uncomment the following line to disable Rhoconnect Front-end console
13
+ #Rhoconnect.disable_rc_console = true
30
14
 
31
- # Load our rhoconnect application
15
+ # Load RhoConnect application
32
16
  require './application'
33
17
 
34
- # Setup the url map
35
- run Rack::URLMap.new \
36
- '/' => Rhoconnect::Server.new,
37
- '/resque' => Resque::Server.new, # If you don't want resque frontend, disable it here
38
- '/console' => RhoconnectConsole::Server.new # If you don't want rhoconnect frontend, disable it here
18
+ # run RhoConnect Application
19
+ run Rhoconnect.app
@@ -0,0 +1,44 @@
1
+ # Rhoconnect app runtime dependencies
2
+ # DO NOT edit this file unless you know what are you doing!
3
+
4
+ # Helps with some of the limitations of green threads, not needed in ruby 1.9.x
5
+ gem 'SystemTimer', '~> 1.2.3', :platforms => :ruby_18
6
+
7
+ # v0.7.x removes Process.fork, need this version for now
8
+ gem 'win32-process', '= 0.6.6', :platforms => [:mswin, :mingw]
9
+
10
+ # use thin and eventmachine everywhere except JRuby
11
+ platforms :ruby, :ruby_19, :mingw, :mingw_19 do
12
+ gem "eventmachine", "~> 1.0.0"
13
+ # using thin by default
14
+ gem 'thin'
15
+ end
16
+
17
+ # for async framework
18
+ # for Async, Eventful execution
19
+ platforms :ruby_19, :mingw_19 do
20
+ gem 'rack-fiber_pool'
21
+ gem 'async-rack'
22
+ end
23
+
24
+ platforms :jruby do
25
+ gem 'jdbc-sqlite3', ">= 3.7.2"
26
+ gem 'dbi', ">= 0.4.5"
27
+ gem 'dbd-jdbc', ">= 0.1.4"
28
+ gem 'jruby-openssl', ">= 0.7.4"
29
+ gem 'trinidad'
30
+ gem 'warbler'
31
+ end
32
+
33
+ # uncomment the line below to use bulk sync: http://docs.rhomobile.com/rhoconnect/bulk-sync
34
+ # gem 'sqlite3', ">= 1.3.3", :platforms => [:ruby, :mswin, :mingw]
35
+
36
+ group :development do
37
+ gem 'rhomobile-debug', ">= 1.0.2"
38
+ end
39
+
40
+ group :test do
41
+ gem 'rspec', '~> 2.10.0'
42
+ gem 'rack-test', '>= 0.5.3', :require => "rack/test"
43
+ gem 'rhomobile-debug', ">= 1.0.2"
44
+ end
@@ -1,17 +1,19 @@
1
- :sources:
1
+ :sources:
2
2
 
3
3
  :development:
4
4
  :licensefile: settings/license.key
5
5
  :redis: localhost:6379
6
6
  :syncserver: http://localhost:9292/api/application/
7
- :push_server: http://appname:secret@localhost:8675/
7
+ :push_server: http://someappname@localhost:8675/
8
+ :api_token: my-rhoconnect-token
8
9
  :test:
9
10
  :licensefile: settings/license.key
10
11
  :redis: localhost:6379
11
12
  :syncserver: http://localhost:9292/api/application/
12
- :push_server: http://appname:secret@localhost:8675/
13
- :production:
13
+ :push_server: http://someappname@localhost:8675/
14
+ :api_token: my-rhoconnect-token
15
+ :production:
14
16
  :licensefile: settings/license.key
15
17
  :redis: localhost:6379
16
18
  :syncserver: http://localhost:9292/api/application/
17
- :push_server: http://appname:secret@localhost:8675/
19
+ :push_server: http://someappname@localhost:8675/
data/install.sh CHANGED
@@ -183,10 +183,10 @@ logAndPrint ()
183
183
  setRubyVars ()
184
184
  {
185
185
  if [[ $rubyVersion == "" || $rubyVersion =~ ruby'ee'|'enterprise' ]]; then
186
- rubyVersion="ruby-1.9.3-p194"
187
- rubyDir="ruby-1.9.3-p194"
186
+ rubyVersion="ruby-1.9.3-p286"
187
+ rubyDir="ruby-1.9.3-p286"
188
188
  rubyTar="${rubyDir}.tar.gz"
189
- # http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
189
+ # http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p286.tar.gz
190
190
  rubyURL="http://ftp.ruby-lang.org/pub/ruby/1.9/${rubyTar}"
191
191
  elif [$rubyVersion == "ruby187"]; then
192
192
  rubyDir="ruby-1.8.7"
@@ -217,7 +217,7 @@ installRuby ()
217
217
  # rubyee)
218
218
  # logAndPrint "${prefix}/${rubyDir}/installer --dont-install-useful-gems --no-dev-docs --auto ${prefix}"
219
219
  # ;;
220
- ruby-1.9.3-p194)
220
+ ruby-1.9.3-p286)
221
221
  (
222
222
  echo "cd ${prefix}/${rubyDir}" | tee -a $log
223
223
  cd ${prefix}/${rubyDir}
@@ -354,7 +354,7 @@ http {
354
354
  access_log logs/access.log time_combined;
355
355
 
356
356
  sendfile on;
357
- keepalive_timeout 120;
357
+ keepalive_timeout 30;
358
358
  client_max_body_size 4m;
359
359
  client_body_buffer_size 128k;
360
360
  #gzip on;
@@ -402,6 +402,10 @@ server {
402
402
  proxy_set_header Host $http_host;
403
403
  proxy_redirect off;
404
404
 
405
+ proxy_connect_timeout 30;
406
+ proxy_send_timeout 30;
407
+ proxy_read_timeout 30;
408
+
405
409
  proxy_pass http://thin_cluster;
406
410
  }
407
411
 
@@ -726,4 +730,5 @@ rescue => ex
726
730
  puts
727
731
  puts "#{ex.message}"
728
732
  exit(1)
729
- end
733
+ end
734
+
@@ -8,10 +8,10 @@ module Constants
8
8
  "libaprutil1-dev",
9
9
  "dtach"]
10
10
 
11
- RUBY = "ruby-1.9.3-p194"
11
+ RUBY = "ruby-1.9.3-p286"
12
12
  REDIS = "redis-2.4.17"
13
13
  SQLITE3 = "sqlite-autoconf-3071000"
14
- NGINX = "nginx-1.3.6"
14
+ NGINX = "nginx-1.3.7"
15
15
  PASSENGER_ROOT = "/opt/rhoconnect/lib/ruby/gems/1.9.1/gems/passenger"
16
16
 
17
17
  SOFTWARE = [ REDIS, SQLITE3, RUBY, NGINX ]
@@ -25,22 +25,7 @@ module Installers
25
25
 
26
26
  # Update the RubyGems system software
27
27
  cmd "#{@gem_path} update --system"
28
- #install_gem 'bundler'
29
- #install_gem 'foreman'
30
- =begin
31
- print_header "Installing eventmachine 1.0.0.beta.4 gem ..."
32
- Dir.chdir("#{@options[:prefix]}")
33
- `wget #{EVENTMACHINE_URL} -o /dev/null;tar xzfv master;rm -rf master`
34
- Dir.chdir("#{@options[:prefix]}/rhomobile-eventmachine-6858b3b/")
35
- cmd("#{@options[:prefix]}/bin/bundle install")
36
- cmd("#{@options[:prefix]}/bin/gem build eventmachine.gemspec 2> /dev/null")
37
- cmd("#{@options[:prefix]}/bin/gem install --local eventmachine-1.0.0.beta.4.gem --no-ri --no-rdoc")
38
- res =$?
39
- Dir.chdir("#{@options[:prefix]}")
40
- cmd("rm -rf master rhomobile-eventmachine-6858b3b")
41
- raise "eventmachine 1.0.0.0.beta4 installation failed." if res != 0
42
- =end
43
- # Install bundler, thin, ...
28
+ # Install bundler
44
29
  GEMS.each do |gem|
45
30
  install_gem gem
46
31
  end
data/lib/rhoconnect.rb CHANGED
@@ -29,34 +29,34 @@ require 'rhoconnect/dynamic_adapter'
29
29
 
30
30
  REDIS_URL = 'REDIS' unless defined? REDIS_URL
31
31
  REDISTOGO_URL = 'REDISTOGO_URL' unless defined? REDISTOGO_URL
32
-
32
+
33
33
  # Various module utilities for the store
34
34
  module Rhoconnect
35
35
  APP_NAME = 'application' unless defined? APP_NAME
36
-
36
+
37
37
  class InvalidArgumentError < RuntimeError; end
38
38
  class RhoconnectServerError < RuntimeError; end
39
-
39
+
40
40
  # Used by application authenticate to indicate login failure
41
41
  class LoginException < RuntimeError; end
42
-
42
+
43
43
  API_VERSION = 'v1'.freeze
44
-
44
+
45
45
  extend self
46
-
46
+
47
47
  class << self
48
- attr_accessor :base_directory, :app_directory, :data_directory,
49
- :vendor_directory, :blackberry_bulk_sync, :redis, :environment,
48
+ attr_accessor :base_directory, :app_directory, :data_directory,
49
+ :vendor_directory, :blackberry_bulk_sync, :redis,
50
50
  :log_disabled, :license, :bulk_sync_poll_interval, :stats, :appserver, :api_token,
51
- :raise_on_expired_lock, :lock_duration, :cookie_expire, :predefined_sources
51
+ :raise_on_expired_lock, :lock_duration, :cookie_expire, :predefined_sources,
52
+ :connection_pool_size, :connection_pool_timeout, :redis_timeout,
53
+ :disable_resque_console, :disable_rc_console
52
54
  end
53
-
54
- ### Begin Rhoconnect setup methods
55
+
56
+ ### Begin Rhoconnect setup methods
55
57
  # Server hook to initialize Rhoconnect
56
58
  def bootstrap(basedir)
57
59
  config = get_config(basedir)
58
- #Load environment
59
- environment = (ENV['RHO_ENV'] || ENV['RACK_ENV'] || :development).to_sym
60
60
  # Initialize Rhoconnect and Resque
61
61
  Rhoconnect.base_directory = basedir
62
62
  Rhoconnect.app_directory = get_setting(config,environment,:app_directory)
@@ -65,29 +65,37 @@ module Rhoconnect
65
65
  Rhoconnect.blackberry_bulk_sync = get_setting(config,environment,:blackberry_bulk_sync,false)
66
66
  Rhoconnect.bulk_sync_poll_interval = get_setting(config,environment,:bulk_sync_poll_interval,3600)
67
67
  Rhoconnect.redis = get_setting(config,environment,:redis,false)
68
+ Rhoconnect.connection_pool_size ||= get_setting(config,environment,:connection_pool_size,5)
69
+ Rhoconnect.connection_pool_timeout = get_setting(config,environment,:connection_pool_timeout,30)
70
+ Rhoconnect.redis_timeout = get_setting(config,environment,:redis_timeout,30)
68
71
  Rhoconnect.api_token = ENV['API_TOKEN'] || get_setting(config,environment,:api_token,false)
69
72
  Rhoconnect.log_disabled = get_setting(config,environment,:log_disabled,false)
70
73
  Rhoconnect.raise_on_expired_lock = get_setting(config,environment,:raise_on_expired_lock,false)
71
74
  Rhoconnect.lock_duration = get_setting(config,environment,:lock_duration)
72
- Rhoconnect.environment = environment
73
75
  Rhoconnect.cookie_expire = get_setting(config,environment,:cookie_expire) || 31536000
74
76
  Rhoconnect.predefined_sources = {}
75
77
  yield self if block_given?
76
78
  Store.create(Rhoconnect.redis)
77
- Resque.redis = Store.db
79
+ Resque.redis = Rhoconnect.redis
78
80
  Rhoconnect.base_directory ||= File.join(File.dirname(__FILE__),'..')
79
81
  Rhoconnect.app_directory ||= Rhoconnect.base_directory
80
82
  Rhoconnect.data_directory ||= File.join(Rhoconnect.base_directory,'data')
81
83
  Rhoconnect.vendor_directory ||= File.join(Rhoconnect.base_directory,'vendor')
82
84
  Rhoconnect.stats ||= false
83
85
  Rhoconnect.license = License.new
84
-
86
+ Rhoconnect.disable_rc_console ||= false
87
+ Rhoconnect.disable_resque_console ||= false
88
+
85
89
  check_and_add(File.join(Rhoconnect.app_directory,'sources'))
86
90
  start_app(config)
87
91
  create_admin_user
88
92
  check_hsql_lib! if Rhoconnect.blackberry_bulk_sync
89
93
  end
90
-
94
+
95
+ def environment
96
+ (ENV['RHO_ENV'] || ENV['RACK_ENV'] || :development).to_sym
97
+ end
98
+
91
99
  def start_app(config)
92
100
  if config and config[Rhoconnect.environment]
93
101
  app = nil
@@ -109,15 +117,15 @@ module Rhoconnect
109
117
  # load ruby file for source adapter to re-load class
110
118
  load under_score(source_name+'.rb')
111
119
  end
112
-
120
+
113
121
  # load all pre-defined adapters files
114
122
  Dir[File.join(File.dirname(__FILE__),'rhoconnect','predefined_adapters','*.rb')].each { |adapter| load adapter }
115
-
123
+
116
124
  # Create associations for all sources
117
125
  Source.update_associations(app.sources)
118
126
  end
119
127
  end
120
-
128
+
121
129
  # Generate admin user on first load
122
130
  def create_admin_user
123
131
  unless User.is_exist?('rhoadmin')
@@ -131,7 +139,7 @@ module Rhoconnect
131
139
 
132
140
  # Add path to load_path unless it has been added already
133
141
  def check_and_add(path)
134
- $:.unshift path unless $:.include?(path)
142
+ $:.unshift path unless $:.include?(path)
135
143
  end
136
144
 
137
145
  def get_config(basedir)
@@ -148,9 +156,10 @@ module Rhoconnect
148
156
  force_default = source_config[:force_default]
149
157
  source_config.delete(:force_default)
150
158
  # apply global env settings
151
- [:poll_interval].each do |setting|
159
+ [:poll_interval, :push_notify].each do |setting|
152
160
  def_setting = env_config["#{setting.to_s}_default".to_sym]
153
- next unless def_setting
161
+ def_setting ||= env_config[setting]
162
+ next unless def_setting
154
163
  if source_config[setting].nil? or force_default
155
164
  source_config[setting] = def_setting
156
165
  end
@@ -161,10 +170,10 @@ module Rhoconnect
161
170
  ### End Rhoconnect setup methods
162
171
  def register_predefined_source(source_name)
163
172
  return if Rhoconnect.predefined_sources.has_key?(source_name)
164
-
173
+
165
174
  Rhoconnect.predefined_sources[source_name] = {:source_loaded => false}
166
175
  end
167
-
176
+
168
177
  def create_predefined_source(source_name,params)
169
178
  source_data = Rhoconnect.predefined_sources[source_name]
170
179
  return unless source_data
@@ -177,16 +186,16 @@ module Rhoconnect
177
186
  source_data[:source_loaded] = true
178
187
  end
179
188
  end
180
-
189
+
181
190
  def check_default_secret!(secret)
182
- if secret == '<changeme>'
191
+ if secret == '<changeme>'
183
192
  log "*"*60+"\n\n"
184
193
  log "WARNING: Change the session secret in config.ru from <changeme> to something secure."
185
194
  log " i.e. running `rake rhoconnect:secret` in your rhoconnect app directory will generate a secret you could use.\n\n"
186
195
  log "*"*60
187
196
  end
188
197
  end
189
-
198
+
190
199
  def check_for_schema_field!(fields)
191
200
  if fields['schema']
192
201
  log "ERROR: 'schema' field in settings.yml is not supported anymore, please use source adapter schema method!"
@@ -212,7 +221,7 @@ module Rhoconnect
212
221
  UUIDTools::UUID.random_create.to_s.gsub(/\-/,'')
213
222
  end
214
223
 
215
- # Generates new token (64-bit integer) based on # of
224
+ # Generates new token (64-bit integer) based on # of
216
225
  # microseconds since Jan 1 2009
217
226
  def get_token
218
227
  ((Time.now.to_f - Time.mktime(2009,"jan",1,0,0,0,0).to_f) * 10**6).to_i
@@ -250,7 +259,7 @@ module Rhoconnect
250
259
  log "*"*60
251
260
  end
252
261
  end
253
-
262
+
254
263
  def expire_bulk_data(username, partition = :user)
255
264
  name = BulkData.get_name(partition,username)
256
265
  data = BulkData.load(name)
@@ -292,22 +301,26 @@ module Rhoconnect
292
301
  def timenow
293
302
  (Time.now.to_f * 1000)
294
303
  end
295
-
304
+
296
305
  def log(*args)
297
306
  now = Time.now.strftime('%I:%M:%S %p %Y-%m-%d')
298
307
  puts "[#{now}] #{args.join}" unless Rhoconnect.log_disabled
299
308
  end
300
-
309
+
301
310
  def self.appserver
302
311
  Store.get_value("appserver_url")
303
312
  end
304
-
313
+
305
314
  def self.appserver=(url)
306
315
  Store.set_value("appserver_url",url)
307
316
  end
308
-
317
+
318
+ def self.settings
319
+ @@settings ||= get_config(Rhoconnect.base_directory || ROOT_PATH)[Rhoconnect.environment]
320
+ end
321
+
309
322
  # Base rhoconnect application class
310
- class Base
323
+ class Base
311
324
  # Add everything in vendor to load path
312
325
  # TODO: Integrate with 3rd party dependency management
313
326
  def self.initializer(path=nil)
@@ -319,16 +332,16 @@ module Rhoconnect
319
332
  # Bootstrap Rhoconnect system
320
333
  Rhoconnect.bootstrap(path || ENV['PWD'])
321
334
  end
322
-
335
+
323
336
  def self.store_blob(obj,field_name,blob)
324
337
  blob[:tempfile].path if blob[:tempfile]
325
338
  end
326
339
  end
327
-
340
+
328
341
  protected
329
342
  def get_setting(config,environment,setting,default=nil)
330
343
  res = nil
331
- res = config[environment][setting] if config and environment
344
+ res = config[environment][setting] if config and environment
332
345
  res || default
333
346
  end
334
347
  end