rhoconnect 3.4.5 → 4.0.0.beta.10

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 (337) hide show
  1. data/CHANGELOG.md +57 -3
  2. data/Gemfile +9 -7
  3. data/Gemfile.lock +37 -37
  4. data/Rakefile +18 -7
  5. data/bench/benchapp/Gemfile +1 -1
  6. data/bench/benchapp/config.ru +0 -3
  7. data/bench/benchapp/controllers/ruby/application.rb +17 -0
  8. data/bench/benchapp/controllers/ruby/application_controller.rb +17 -0
  9. data/bench/benchapp/controllers/ruby/mock_adapter_controller.rb +8 -0
  10. data/bench/benchapp/controllers/ruby/queue_mock_adapter_controller.rb +8 -0
  11. data/bench/benchapp/{sources → models/ruby}/mock_adapter.rb +1 -1
  12. data/bench/benchapp/{sources → models/ruby}/queue_mock_adapter.rb +0 -0
  13. data/bench/benchapp/spec/{sources → models/ruby}/mock_adapter_spec.rb +1 -1
  14. data/bench/benchapp/spec/{sources → models/ruby}/queue_mock_adapter_spec.rb +1 -1
  15. data/bench/benchapp/spec/spec_helper.rb +2 -2
  16. data/bench/blobapp/Gemfile +1 -1
  17. data/bench/blobapp/config.ru +0 -3
  18. data/bench/blobapp/controllers/ruby/application_controller.rb +17 -0
  19. data/bench/blobapp/controllers/ruby/blob_adapter_controller.rb +8 -0
  20. data/bench/blobapp/{sources → models/ruby}/blob_adapter.rb +9 -2
  21. data/bench/blobapp/spec/{sources → models/ruby}/blob_adapter_spec.rb +1 -1
  22. data/bench/blobapp/spec/spec_helper.rb +1 -1
  23. data/bench/lib/bench/cli.rb +1 -1
  24. data/bench/scripts/blob_cud_script.rb +1 -1
  25. data/bench/scripts/query_md_script.rb +1 -1
  26. data/bench/scripts/query_only_script.rb +1 -1
  27. data/bench/scripts/query_script.rb +1 -1
  28. data/bench/scripts/test_query_script.rb +7 -1
  29. data/bench/spec/mock_adapter_spec.rb +1 -1
  30. data/bench/spec/result_spec.rb +3 -3
  31. data/bin/rhoconnect +5 -3
  32. data/commands/dtach/dtach_install.rb +2 -2
  33. data/commands/execute.rb +8 -3
  34. data/commands/generators/app.rb +3 -3
  35. data/commands/generators/controller.rb +6 -0
  36. data/commands/generators/model.rb +6 -0
  37. data/commands/generators/source.rb +3 -3
  38. data/commands/generators/update.rb +1 -1
  39. data/commands/redis/redis_about.rb +2 -2
  40. data/commands/redis/redis_download.rb +1 -1
  41. data/commands/redis/redis_install.rb +4 -3
  42. data/commands/redis/redis_restart.rb +4 -4
  43. data/commands/redis/redis_start.rb +5 -4
  44. data/commands/redis/redis_startbg.rb +5 -4
  45. data/commands/redis/redis_status.rb +13 -0
  46. data/commands/redis/redis_stop.rb +3 -3
  47. data/commands/rhoconnect/config.rb +28 -16
  48. data/commands/rhoconnect/flushdb.rb +1 -2
  49. data/commands/rhoconnect/get_token.rb +15 -11
  50. data/commands/rhoconnect/restart.rb +13 -5
  51. data/commands/rhoconnect/set_admin_password.rb +8 -8
  52. data/commands/rhoconnect/start.rb +74 -16
  53. data/commands/rhoconnect/startbg.rb +1 -1
  54. data/commands/rhoconnect/startdebug.rb +1 -1
  55. data/commands/rhoconnect/stop.rb +13 -1
  56. data/commands/rhoconnect/web.rb +5 -5
  57. data/commands/rhoconnect_console/console.rb +7 -5
  58. data/commands/{rhoconnect → rhoconnect_spec}/spec.rb +0 -0
  59. data/commands/rhoconnect_war/war.rb +9 -9
  60. data/commands/utilities/blank_app.ru +56 -0
  61. data/commands/utilities/redis_runner.rb +54 -19
  62. data/doc/authentication.txt +80 -6
  63. data/doc/blob-sync.txt +104 -97
  64. data/doc/bulk-sync.txt +1 -1
  65. data/doc/client-java.txt +3 -3
  66. data/doc/client-objc.txt +2 -2
  67. data/doc/client.txt +4 -4
  68. data/doc/command-line.txt +105 -200
  69. data/doc/data-partitioning.txt +40 -0
  70. data/doc/deploying.txt +249 -77
  71. data/doc/extending-rhoconnect-server.txt +40 -57
  72. data/doc/heroku-addon.txt +2 -0
  73. data/doc/install.txt +45 -95
  74. data/doc/introduction.txt +1 -1
  75. data/doc/java-plugin.txt +365 -190
  76. data/doc/metadata.txt +1 -1
  77. data/doc/migration.txt +108 -142
  78. data/doc/preparing-production.txt +1 -1
  79. data/doc/push-backend-setup.txt +2 -0
  80. data/doc/push-client-setup-android.txt +78 -0
  81. data/doc/push-client-setup-bb.txt +81 -0
  82. data/doc/push-client-setup-ios.txt +70 -0
  83. data/doc/push-client-setup-rps.txt +200 -0
  84. data/doc/push-client-setup.txt +63 -66
  85. data/doc/push-server-setup.txt +67 -40
  86. data/doc/push-testing.txt +29 -0
  87. data/doc/push.txt +21 -6
  88. data/doc/rest-api.txt +128 -55
  89. data/doc/rhoconnect-redis-stack.txt +120 -0
  90. data/doc/settings.txt +4 -12
  91. data/doc/source-adapters-intro.txt +28 -0
  92. data/doc/source-adapters.txt +235 -272
  93. data/doc/stats-middleware.txt +9 -29
  94. data/doc/supported-platforms.txt +21 -30
  95. data/doc/testing.txt +40 -42
  96. data/doc/tutorial.txt +72 -57
  97. data/examples/simple/Gemfile +1 -1
  98. data/examples/simple/application.rb +4 -5
  99. data/examples/simple/my_server.rb +2 -2
  100. data/examples/simple/settings/settings.yml +1 -1
  101. data/generators/rhoconnect.rb +151 -50
  102. data/generators/templates/application/Gemfile +1 -1
  103. data/generators/templates/application/Rakefile +3 -3
  104. data/generators/templates/application/config.ru +1 -4
  105. data/generators/templates/application/controllers/application_controller.rb +17 -0
  106. data/generators/templates/application/controllers/js/application_controller.js +14 -0
  107. data/generators/templates/application/controllers/ruby/application_controller.rb +17 -0
  108. data/generators/templates/application/package.json +8 -0
  109. data/generators/templates/application/rcgemfile +2 -5
  110. data/generators/templates/application/settings/settings.yml +3 -3
  111. data/generators/templates/application/spec/application_controller_spec.rb +23 -0
  112. data/generators/templates/application/spec/js_spec.rb +25 -0
  113. data/generators/templates/application/spec/spec_helper.rb +21 -7
  114. data/generators/templates/source/controllers/js/controller.js +7 -0
  115. data/generators/templates/source/controllers/ruby/controller.rb +8 -0
  116. data/generators/templates/source/controllers/ruby/controller_spec.rb +27 -0
  117. data/generators/templates/source/models/js/model.js +46 -0
  118. data/generators/templates/source/{source_adapter.rb → models/ruby/model.rb} +15 -10
  119. data/generators/templates/source/{source_spec.rb → models/ruby/model_spec.rb} +1 -1
  120. data/install.sh +5 -5
  121. data/installer/unix-like/create_texts.rb +2 -2
  122. data/installer/unix-like/rho_connect_install_constants.rb +2 -2
  123. data/installer/unix-like/rho_connect_install_utilities.rb +1 -1
  124. data/installer/utils/constants.rb +4 -4
  125. data/js-adapters/ballroom.js +216 -0
  126. data/js-adapters/node.rb +52 -0
  127. data/js-adapters/node_channel.rb +181 -0
  128. data/js-adapters/request.js +27 -0
  129. data/js-adapters/response.js +57 -0
  130. data/js-adapters/rhoconnect_helpers.js +60 -0
  131. data/js-adapters/router.js +60 -0
  132. data/js-adapters/server.js +5 -0
  133. data/lib/rhoconnect/api/app/ans_login.rb +3 -3
  134. data/lib/rhoconnect/api/app/bulk_data.rb +10 -10
  135. data/lib/rhoconnect/api/app/fast_delete.rb +11 -10
  136. data/lib/rhoconnect/api/app/fast_insert.rb +11 -10
  137. data/lib/rhoconnect/api/app/fast_update.rb +11 -10
  138. data/lib/rhoconnect/api/app/login.rb +5 -5
  139. data/lib/rhoconnect/api/app/push_deletes.rb +12 -11
  140. data/lib/rhoconnect/api/app/push_objects.rb +12 -11
  141. data/lib/rhoconnect/api/app/query.rb +8 -7
  142. data/lib/rhoconnect/api/app/queue_updates.rb +98 -94
  143. data/lib/rhoconnect/api/app/search.rb +8 -7
  144. data/lib/rhoconnect/api/client/client_get_db_doc.rb +5 -5
  145. data/lib/rhoconnect/api/client/client_set_db_doc.rb +8 -8
  146. data/lib/rhoconnect/api/client/create.rb +7 -7
  147. data/lib/rhoconnect/api/client/get_client_params.rb +4 -4
  148. data/lib/rhoconnect/api/client/list_client_docs.rb +17 -17
  149. data/lib/rhoconnect/api/client/register.rb +12 -12
  150. data/lib/rhoconnect/api/client/reset.rb +5 -5
  151. data/lib/rhoconnect/api/readstate/set_refresh_time.rb +9 -9
  152. data/lib/rhoconnect/api/source/get_source_params.rb +4 -4
  153. data/lib/rhoconnect/api/source/list_sources.rb +16 -16
  154. data/lib/rhoconnect/api/source/update_source_params.rb +6 -6
  155. data/lib/rhoconnect/api/store/get_db_doc.rb +4 -4
  156. data/lib/rhoconnect/api/store/set_db_doc.rb +7 -7
  157. data/lib/rhoconnect/api/system/get_adapter.rb +4 -4
  158. data/lib/rhoconnect/api/system/get_license_info.rb +8 -8
  159. data/lib/rhoconnect/api/system/login.rb +15 -15
  160. data/lib/rhoconnect/api/system/reset.rb +11 -11
  161. data/lib/rhoconnect/api/system/save_adapter.rb +4 -4
  162. data/lib/rhoconnect/api/system/stats.rb +22 -22
  163. data/lib/rhoconnect/api/user/create_user.rb +7 -7
  164. data/lib/rhoconnect/api/user/delete_client.rb +6 -6
  165. data/lib/rhoconnect/api/user/delete_user.rb +11 -10
  166. data/lib/rhoconnect/api/user/list_clients.rb +4 -4
  167. data/lib/rhoconnect/api/user/list_source_docs.rb +10 -10
  168. data/lib/rhoconnect/api/user/list_users.rb +3 -3
  169. data/lib/rhoconnect/api/user/ping.rb +3 -3
  170. data/lib/rhoconnect/api/user/show_user.rb +3 -3
  171. data/lib/rhoconnect/api/user/update_user.rb +5 -5
  172. data/lib/rhoconnect/api/user/user_get_db_doc.rb +5 -5
  173. data/lib/rhoconnect/api/user/user_set_db_doc.rb +10 -10
  174. data/lib/rhoconnect/api_token.rb +5 -6
  175. data/lib/rhoconnect/app.rb +6 -46
  176. data/lib/rhoconnect/application/init.rb +5 -2
  177. data/lib/rhoconnect/async.rb +76 -39
  178. data/lib/rhoconnect/bulk_data/bulk_data.rb +6 -4
  179. data/lib/rhoconnect/client.rb +59 -9
  180. data/lib/rhoconnect/condition/admin_required.rb +27 -0
  181. data/lib/rhoconnect/condition/client_required.rb +50 -0
  182. data/lib/rhoconnect/condition/login_required.rb +22 -0
  183. data/lib/rhoconnect/condition/source_required.rb +49 -0
  184. data/lib/rhoconnect/condition/verbs.rb +17 -0
  185. data/lib/rhoconnect/condition/verify_success.rb +19 -0
  186. data/lib/rhoconnect/controller/app_base.rb +74 -0
  187. data/lib/rhoconnect/controller/base.rb +68 -0
  188. data/lib/rhoconnect/controller/clients_controller.rb +79 -0
  189. data/lib/rhoconnect/controller/dynamic_adapter_controller.rb +93 -0
  190. data/lib/rhoconnect/controller/js_base.rb +124 -0
  191. data/lib/rhoconnect/controller/read_state_controller.rb +22 -0
  192. data/lib/rhoconnect/controller/source_adapter_base.rb +14 -0
  193. data/lib/rhoconnect/controller/sources_controller.rb +44 -0
  194. data/lib/rhoconnect/controller/store_controller.rb +25 -0
  195. data/lib/rhoconnect/controller/system_controller.rb +67 -0
  196. data/lib/rhoconnect/controller/users_controller.rb +99 -0
  197. data/lib/rhoconnect/db_adapter.rb +1 -3
  198. data/lib/rhoconnect/document.rb +159 -50
  199. data/lib/rhoconnect/handler/authenticate/execute_methods.rb +77 -0
  200. data/lib/rhoconnect/handler/authenticate/runner.rb +49 -0
  201. data/lib/rhoconnect/handler/authenticate.rb +3 -0
  202. data/lib/rhoconnect/handler/bulk_data.rb +28 -0
  203. data/lib/rhoconnect/handler/changes/engine.rb +271 -0
  204. data/lib/rhoconnect/handler/changes/execute_methods.rb +88 -0
  205. data/lib/rhoconnect/handler/changes/pass_through_runner.rb +11 -0
  206. data/lib/rhoconnect/handler/changes/runner.rb +53 -0
  207. data/lib/rhoconnect/handler/changes.rb +31 -0
  208. data/lib/rhoconnect/handler/helpers/auth_method.rb +29 -0
  209. data/lib/rhoconnect/handler/helpers/binding.rb +18 -0
  210. data/lib/rhoconnect/handler/helpers/bulk_data.rb +53 -0
  211. data/lib/rhoconnect/handler/helpers/source_job.rb +14 -0
  212. data/lib/rhoconnect/handler/helpers.rb +4 -0
  213. data/lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb +99 -0
  214. data/lib/rhoconnect/handler/plugin_callbacks/runner.rb +28 -0
  215. data/lib/rhoconnect/handler/plugin_callbacks.rb +67 -0
  216. data/lib/rhoconnect/handler/query/engine.rb +93 -0
  217. data/lib/rhoconnect/handler/query/execute_methods.rb +21 -0
  218. data/lib/rhoconnect/handler/query/pass_through_runner.rb +35 -0
  219. data/lib/rhoconnect/handler/query/runner.rb +270 -0
  220. data/lib/rhoconnect/handler/query.rb +19 -0
  221. data/lib/rhoconnect/handler/search/engine.rb +60 -0
  222. data/lib/rhoconnect/handler/search/execute_methods.rb +32 -0
  223. data/lib/rhoconnect/handler/search/pass_through_runner.rb +18 -0
  224. data/lib/rhoconnect/handler/search/runner.rb +104 -0
  225. data/lib/rhoconnect/handler/search.rb +26 -0
  226. data/lib/rhoconnect/handler/sync.rb +29 -0
  227. data/lib/rhoconnect/jobs/source_job.rb +13 -4
  228. data/lib/rhoconnect/js_adapter.rb +79 -0
  229. data/lib/rhoconnect/license.rb +10 -2
  230. data/lib/rhoconnect/middleware/current_user.rb +14 -1
  231. data/lib/rhoconnect/middleware/helpers.rb +10 -93
  232. data/lib/rhoconnect/middleware/x_domain_session_wrapper.rb +1 -1
  233. data/lib/rhoconnect/model/base.rb +229 -0
  234. data/lib/rhoconnect/model/dynamic_adapter_model.rb +90 -0
  235. data/lib/rhoconnect/model/js_base.rb +121 -0
  236. data/lib/rhoconnect/ping/android.rb +1 -1
  237. data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +7 -4
  238. data/lib/rhoconnect/read_state.rb +3 -3
  239. data/lib/rhoconnect/server.rb +159 -190
  240. data/lib/rhoconnect/source.rb +100 -11
  241. data/lib/rhoconnect/stats/record.rb +10 -10
  242. data/lib/rhoconnect/store.rb +905 -591
  243. data/lib/rhoconnect/{model.rb → store_orm.rb} +53 -115
  244. data/lib/rhoconnect/tasks.rb +18 -4
  245. data/lib/rhoconnect/test_methods.rb +30 -17
  246. data/lib/rhoconnect/user.rb +35 -17
  247. data/lib/rhoconnect/utilities.rb +1 -1
  248. data/lib/rhoconnect/version.rb +2 -2
  249. data/lib/rhoconnect/web-console/server.rb +29 -14
  250. data/lib/rhoconnect/web-console/views/home.js +10 -10
  251. data/lib/rhoconnect/web-console/views/new_ping.js +1 -1
  252. data/lib/rhoconnect.rb +120 -51
  253. data/rhoconnect.gemspec +4 -3
  254. data/spec/api/api_helper.rb +1 -6
  255. data/spec/api/app/fast_delete_spec.rb +4 -4
  256. data/spec/api/app/fast_insert_spec.rb +4 -4
  257. data/spec/api/app/fast_update_spec.rb +8 -8
  258. data/spec/api/app/push_deletes_spec.rb +2 -2
  259. data/spec/api/app/push_objects_spec.rb +5 -5
  260. data/spec/api/client/client_get_db_doc_spec.rb +6 -4
  261. data/spec/api/client/client_set_db_doc_spec.rb +3 -2
  262. data/spec/api/client/get_client_params_spec.rb +14 -0
  263. data/spec/api/client/list_client_docs_spec.rb +30 -20
  264. data/spec/api/client/reset_spec.rb +36 -0
  265. data/spec/api/source/get_source_params_spec.rb +23 -17
  266. data/spec/api/system/get_license_info_spec.rb +0 -20
  267. data/spec/api/system/login_spec.rb +8 -0
  268. data/spec/api/system/reset_spec.rb +0 -1
  269. data/spec/api/system/stats_spec.rb +5 -5
  270. data/spec/api/user/create_user_spec.rb +14 -6
  271. data/spec/api/user/delete_user_spec.rb +20 -18
  272. data/spec/api/user/list_users_spec.rb +5 -6
  273. data/spec/api/user/update_user_spec.rb +5 -4
  274. data/spec/apps/rhotestapp/config.ru +16 -1
  275. data/spec/apps/rhotestapp/controllers/js/js_sample_controller.js +23 -0
  276. data/spec/apps/rhotestapp/controllers/js/sample2_controller.js +32 -0
  277. data/spec/apps/rhotestapp/controllers/ruby/application_controller.rb +21 -0
  278. data/spec/apps/rhotestapp/controllers/ruby/sample_adapter_controller.rb +8 -0
  279. data/spec/apps/rhotestapp/models/js/js_sample.js +55 -0
  280. data/spec/apps/rhotestapp/models/js/sample2.js +25 -0
  281. data/spec/apps/rhotestapp/{sources → models/ruby}/base_adapter.rb +0 -0
  282. data/spec/apps/rhotestapp/{sources → models/ruby}/fixed_schema_adapter.rb +0 -0
  283. data/spec/apps/rhotestapp/{sources → models/ruby}/other_adapter.rb +0 -0
  284. data/spec/apps/rhotestapp/{sources → models/ruby}/sample_adapter.rb +0 -0
  285. data/spec/apps/rhotestapp/{sources → models/ruby}/simple_adapter.rb +2 -2
  286. data/spec/apps/rhotestapp/{sources → models/ruby}/sub_adapter.rb +0 -0
  287. data/spec/apps/rhotestapp/settings/settings.yml +0 -1
  288. data/spec/bulk_data/bulk_data_spec.rb +20 -5
  289. data/spec/cli/cli_spec.rb +83 -0
  290. data/spec/client_spec.rb +20 -17
  291. data/spec/client_sync_spec.rb +244 -406
  292. data/spec/controllers/js_base_spec.rb +89 -0
  293. data/spec/doc/doc_spec.rb +18 -18
  294. data/spec/document_spec.rb +29 -13
  295. data/spec/dynamic_adapter_spec.rb +6 -6
  296. data/spec/generator/generator_spec.rb +7 -4
  297. data/spec/jobs/bulk_data_job_spec.rb +14 -10
  298. data/spec/jobs/source_job_spec.rb +8 -8
  299. data/spec/license_spec.rb +5 -2
  300. data/spec/models/js_model_spec.rb +39 -0
  301. data/spec/node_spec.rb +42 -0
  302. data/spec/perf/store_perf_spec.rb +67 -12
  303. data/spec/ping/android_spec.rb +1 -1
  304. data/spec/read_state_spec.rb +1 -1
  305. data/spec/rhoconnect_spec.rb +1 -1
  306. data/spec/server/cors_spec.rb +14 -18
  307. data/spec/server/server_spec.rb +265 -88
  308. data/spec/server/stats_spec.rb +1 -1
  309. data/spec/source_adapter_spec.rb +54 -27
  310. data/spec/source_spec.rb +8 -3
  311. data/spec/source_sync_spec.rb +538 -468
  312. data/spec/spec_helper.rb +35 -4
  313. data/spec/stats/record_spec.rb +10 -10
  314. data/spec/{model_spec.rb → store_orm_spec.rb} +56 -54
  315. data/spec/store_spec.rb +159 -179
  316. data/spec/support/shared_examples.rb +36 -27
  317. data/spec/sync_states_spec.rb +40 -33
  318. data/spec/test_methods_spec.rb +18 -14
  319. data/spec/user_spec.rb +17 -30
  320. metadata +156 -52
  321. data/bench/benchapp/application.rb +0 -39
  322. data/bench/blobapp/application.rb +0 -44
  323. data/commands/rhoconnect/clean_start.rb +0 -9
  324. data/commands/rhoconnect/create_user.rb +0 -18
  325. data/commands/rhoconnect/delete_device.rb +0 -9
  326. data/commands/rhoconnect/delete_user.rb +0 -8
  327. data/commands/rhoconnect/reset.rb +0 -16
  328. data/commands/rhoconnect/reset_refresh.rb +0 -11
  329. data/generators/templates/application/application.rb +0 -43
  330. data/lib/rhoconnect/client_sync.rb +0 -434
  331. data/lib/rhoconnect/dynamic_adapter.rb +0 -91
  332. data/lib/rhoconnect/middleware/admin_user.rb +0 -23
  333. data/lib/rhoconnect/middleware/current_request.rb +0 -16
  334. data/lib/rhoconnect/middleware/login_required.rb +0 -22
  335. data/lib/rhoconnect/source_adapter.rb +0 -132
  336. data/lib/rhoconnect/source_sync.rb +0 -464
  337. data/spec/apps/rhotestapp/application.rb +0 -23
data/doc/deploying.txt CHANGED
@@ -3,8 +3,6 @@
3
3
  ## Deploying On-Premise
4
4
  The [sinatra book](http://sinatra-book.gittr.com/) has some great [deployment documentation](http://sinatra-book.gittr.com/#deployment) that you should review before running your RhoConnect application in production.
5
5
 
6
- We recommend using the [phusion passenger](http://modrails.com/index.html) stack for deploying an on-premise RhoConnect application. Please refer to the [section on rack applications](http://modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_rack_based_ruby_application) for information on deploying a RhoConnect sinatra application.
7
-
8
6
  ## Deploying packaged RhoConnect software on Linux servers
9
7
 
10
8
  You can create RhoConnect production environment on Linux servers by installing software packages
@@ -12,16 +10,16 @@ for Ubuntu and CentOS respectively. At this moment supported formats are Debian
12
10
 
13
11
  Every package provides the following components:
14
12
 
15
- * Ruby 1.9.3-p194
16
-
17
- * Nginx HTTP server, release 1.2.x
13
+ * Ruby 1.9.3-p392
14
+
15
+ * Nginx HTTP server, release 1.3.x
16
+
17
+ * Thin application server, release 1.5.x
18
18
 
19
- * Thin application server, release 1.3.1
19
+ * Redis data store, release 2.6.x
20
20
 
21
- * Redis data store, release 2.4.x
21
+ * Latest RhoConnect gem with all required dependencies
22
22
 
23
- * Latest RhoConnect gem with all required dependencies
24
-
25
23
  In addition, RPM package provides latest sqlite3 headers and binaries, because standard Cent OS (5.x) libraries for sqlite3 outdated.
26
24
 
27
25
  ### Getting the Packages
@@ -33,6 +31,9 @@ Add the following line to the end of your <b>/etc/apt/sources.list</b>:
33
31
 
34
32
  :::text
35
33
  deb http://rhoconnect.s3.amazonaws.com/packages/deb rhoconnect main
34
+
35
+ **NOTE: If you want to get the package with cool new features from the Beta repository, then define
36
+ repo url as `http://rhoconnect.s3.amazonaws.com/beta-packages/deb`**
36
37
 
37
38
  Once the repo is added apt-get needs to be updated:
38
39
 
@@ -45,26 +46,31 @@ Once that is done, it is time to install RhoConnect:
45
46
  $ sudo apt-get install rhoconnect
46
47
 
47
48
  #### Steps for RedHat-Based Linux Users
48
- Vanilla CentOS distribution does not include some packages required by RhoConnect installer. To resolve dependencies you might wanted to use either
49
- [RPMForge](http://wiki.centos.org/AdditionalResources/Repositories/RPMForge) or [Extra Packages for Enterprise Linux (EPEL) ](http://fedoraproject.org/wiki/EPEL)
50
- repository.
49
+ Prerequisites: target Linux server should include CentOS Development tools.
50
+ To install them, use the this command
51
51
 
52
- For example, to add rpmforge repository for CentOS 5.8 release and x86_64 architecture execute this command:
52
+ :::term
53
+ $ yum groupinstall 'Development Tools'
54
+
55
+ It will install for you such tools as GNU GCC C/C++ compiler, make and others.
53
56
 
54
- :::term
55
- $ wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm; rpm -Uhv rpmforge*
57
+ Vanilla CentOS distribution does not include some packages required by RhoConnect installer. To resolve dependencies you
58
+ might wanted to use [Extra Packages for Enterprise Linux (EPEL) ](http://fedoraproject.org/wiki/EPEL)
59
+ repository.
56
60
 
57
- For CentOS 6.2 release:
61
+ For example, to enable EPEL repository for CentOS 5.x release execute these commands:
58
62
 
59
63
  :::term
60
- $ wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm; rpm -Uhv rpmforge*
64
+ $ wget http://mirror.us.leaseweb.net/epel/5/i386/epel-release-5-4.noarch.rpm
65
+ $ rpm -i epel-release-5-4.noarch.rpm
66
+ $ yum update
61
67
 
62
- If you'd rather prefer EPEL repo, then run one of
68
+ For CentOS 6.x release:
63
69
 
64
70
  :::term
65
- $ wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
66
- $ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
67
-
71
+ $ wget http://ftp.osuosl.org/pub/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
72
+ $ rpm -i epel-release-6-8.noarch.rpm
73
+ $ yum update
68
74
 
69
75
  Now you can create a file named <b>rhoconnect.repo</b> in the <b>/etc/yum.repos.d/</b> directory:
70
76
 
@@ -80,6 +86,8 @@ Copy and paste these contents into the file.
80
86
  enabled=1
81
87
  gpgcheck=0
82
88
 
89
+ **NOTE: If you want to get the package with cool new features from the Beta repository, then define baseurl as
90
+ `baseurl=http://rhoconnect.s3.amazonaws.com/beta-packages/rpm`**
83
91
 
84
92
  Once that is done, it is time to install RhoConnect:
85
93
 
@@ -88,12 +96,12 @@ Once that is done, it is time to install RhoConnect:
88
96
 
89
97
  ### Final Steps (After the installer is finished)
90
98
  Installer also created and configured RhoConnect <b>rhoapp</b> application in <b>/opt/nginx/html</b> directory.
91
- To test it you need to as a root user start redis, nginx, and thin servers:
99
+ To test it you need to as a root user start redis, thin, and nginx servers:
92
100
 
93
101
  :::term
94
102
  $ sudo /etc/init.d/redis start
95
- $ sudo /etc/init.d/nginx start
96
103
  $ sudo /etc/init.d/thin start
104
+ $ sudo /etc/init.d/nginx start
97
105
 
98
106
  And verify that it's up and running by visiting application web console in your browser:
99
107
 
@@ -106,7 +114,7 @@ Installer compiled and configured Nginx as reverse proxy web server (/opt/nginx)
106
114
 
107
115
  * Nginx logrotate settings (`/etc/logrotate.d/nginx`)
108
116
 
109
- * Nginx configuration file (`/opt/nginx/conf/nginx.conf`)
117
+ * Nginx configuration file (`/opt/nginx/conf/nginx.conf`)
110
118
 
111
119
  * virtual host template for rhoconnect application (`/opt/nginx/conf/conf.d/rhoconnect.conf`)
112
120
 
@@ -120,7 +128,7 @@ Default setup of Nginx server is to deal with back-end servers (called "upstream
120
128
 
121
129
  :::text
122
130
  # /opt/nginx/conf/conf.d/rhoconnect.conf file
123
-
131
+
124
132
  upstream thin_cluster {
125
133
  least_conn;
126
134
  server unix:/tmp/thin.0.sock;
@@ -129,11 +137,11 @@ Default setup of Nginx server is to deal with back-end servers (called "upstream
129
137
  #server unix:/tmp/thin.2.sock;
130
138
  #server unix:/tmp/thin.3.sock;
131
139
  }
132
-
140
+
133
141
  server {
134
142
  listen 80;
135
143
  # Be sure to point to 'public' folder of your application!
136
- root /opt/nginx/html/rhoapp/public;
144
+ root /opt/nginx/html/rhoapp/public;
137
145
  # ...
138
146
 
139
147
  }
@@ -160,7 +168,7 @@ Configuration file is generated by this command:
160
168
  :::term
161
169
  $ thin config -C /etc/thin/rhoapp.yml -c /opt/nginx/html/rhoapp/ --socket /tmp/thin.sock --servers 2 --log /var/log/thin/thin.log --pid /var/run/thin/thin.pid -e production
162
170
 
163
- ### Development and deployment of RhoConnect applications
171
+ ### Development and deployment of RhoConnect applications
164
172
 
165
173
  Packaged software does not setup automatically path to installed ruby bins and gems, so you need do it manually. Add necessary bins to the path(s) of the users who will be using this software. You may also wish to add these items
166
174
  to your bash scripts (i.e. `~/.profile` on Ubuntu; `~/.bash_profile` on CentOS) to automatically add them upon login.
@@ -168,6 +176,8 @@ to your bash scripts (i.e. `~/.profile` on Ubuntu; `~/.bash_profile` on CentOS)
168
176
  :::text
169
177
  export PATH=/opt/rhoconnect/bin:$PATH
170
178
 
179
+ #### Deploying a rhoconnect app
180
+
171
181
  To deploy and develop your rhoconnect app on nginx and thin servers
172
182
 
173
183
  a) Copy your rhoconnect project (lets name it as `your_rhoconnect_app`) to default location to `/opt/nginx/html` directory
@@ -179,33 +189,33 @@ b) Set up for it `nginx` owner
179
189
  $ sudo chown -R nginx:nginx your_rhoconnect_app/
180
190
 
181
191
  c) Make sure that your app is bundled properly
182
-
192
+
183
193
  :::term
184
194
  $ cd your_rhoconnect_app
185
195
  $ sudo /opt/rhoconnect/bin/bundle install
186
196
 
187
- d) Configure Nginx virtual host for your rhoconnect application. For that edit the file
197
+ d) Configure Nginx virtual host for your rhoconnect application. For that edit the file
188
198
  `/opt/nginx/conf/conf.d/rhoconnect.conf`, so that it reflects your specifications (root directive)
189
199
 
190
200
  :::text
191
201
  # ...
192
202
  server {
193
203
  listen 80;
194
- # Be sure your app have 'public' folder and root directive
204
+ # Be sure your app have 'public' folder and root directive
195
205
  # point to it!
196
206
  root /opt/nginx/html/your_rhoconnect_app/public;
197
207
  # ...
198
208
  }
199
209
 
200
- e) Edit Thin `/etc/thin/rhoapp.yml` configuration file directly
210
+ e) Edit Thin `/etc/thin/rhoapp.yml` configuration file directly
201
211
 
202
212
  :::yaml
203
213
  ---
204
214
  chdir: /opt/nginx/html/your_rhoconnect_app
205
215
  # ...
206
-
216
+
207
217
  or as root user generate a new one
208
-
218
+
209
219
  :::term
210
220
  $ env PATH=/opt/rhoconnect/bin:$PATH thin config -C /etc/thin/your_rhoconnect_app.yml \
211
221
  -c /opt/nginx/html/your_rhoconnect_app/ \
@@ -213,25 +223,155 @@ e) Edit Thin `/etc/thin/rhoapp.yml` configuration file directly
213
223
  --user nginx --group nginx \
214
224
  --pid /var/run/thin/thin.pid -e production
215
225
 
216
- f) As root user restart Nginx, and Thin servers
217
-
226
+ f) As root user restart Thin, and Nginx servers
227
+
218
228
  :::term
219
- /etc/init.d/nginx restart
220
229
  /etc/init.d/thin restart
230
+ /etc/init.d/nginx restart
231
+
232
+
233
+ #### Deploying multiple rhoconnect apps
234
+
235
+ **NOTE: Deploying multiple rhoconnect apps on nginx has not yet been tested. Perform these steps only if you are experienced with nginx.**
236
+
237
+ To deploy and develop two rhoconnect applications on nginx and thin servers,
238
+ refer to the nginx documentation on [nginx server blocks](http://wiki.nginx.org/ServerBlockExample) to see how to configure an nginx sever for multiple host names.
239
+
240
+ For each rhoconnect app, you need to set up its own redis instance. Refer to [the redis quick start documentation](http://redis.io/topics/quickstart).
241
+
242
+ If you have questions on setting this up, contact your system administrator.
243
+
244
+ #### Monitoring and Logging
221
245
 
222
246
  For monitoring and troubleshooting purposes visit web console of your app and look at log files in `/opt/nginx/logs`.
223
247
 
224
- Also you can use RhoConnect `/opt/nginx/html/rhoapp` application as a template and modify it as you wanted.
248
+ Also you can use RhoConnect `/opt/nginx/html/rhoapp` application as a template and modify it as you wanted.
225
249
 
226
- **NOTE: You should pay attentions to situations, if you have already Ruby installed on system level. Avoid usage of system gems in your application. It might lead to unpredictable results, if ruby versions are different. Either set up path to rhoconnect binaries for root user,
250
+ **NOTE: You should pay attentions to situations, if you have already Ruby installed on system level. Avoid usage of system gems in your application. It might lead to unpredictable results, if ruby versions are different. Either set up path to rhoconnect binaries for root user,
227
251
  or install required gems as `sudo /opt/rhoconnect/bin/gem install gem_name`**
228
252
 
253
+ ## Nginx configuration for SSL with self-signed certificate
254
+
255
+ ### About Self-Signed Certificates
256
+ A SSL certificate is a way to encrypt a site's information and create a more secure connection.
257
+ This chapter will take you through generating a self-signed certificate to use with Nginx.
258
+
259
+ ### Create a Directory for the Certificate
260
+ The SSL certificate has 2 main parts: the certificate itself and the public key. To make all of the relevant files easy to access, you should create a directory to store them in:
261
+
262
+ :::term
263
+ $ sudo mkdir /opt/nginx/ssl
264
+
265
+ We will perform the next few steps within the directory:
266
+
267
+ :::term
268
+ $ cd /opt/nginx/ssl
269
+
270
+
271
+ ### Create the Server Key and Certificate Signing Request
272
+ Start by creating the private server key. During this process, you will be asked to enter a specific passphrase. Be sure to note this phrase carefully, if you forget it or lose it, you will not be able to access the certificate.
273
+
274
+ :::term
275
+ $ openssl genrsa -des3 -out server.key 1024
276
+ Generating RSA private key, 1024 bit long modulus
277
+ ..........++++++
278
+ ..................++++++
279
+ e is 65537 (0x10001)
280
+ Enter pass phrase for server.key:
281
+ Verifying - Enter pass phrase for server.key:
282
+
283
+ Follow up by creating a certificate signing request:
284
+
285
+ :::term
286
+ $ openssl req -new -key server.key -out server.csr
287
+
288
+ This command will prompt terminal to display a lists of fields that need to be filled in.
289
+ The most important line is "Common Name". Enter your official domain name here or,
290
+ if you don't have one yet, your site's IP address. Leave the challenge password and optional company name blank.
291
+ :::term
292
+ Enter pass phrase for server.key:
293
+ You are about to be asked to enter information that will be incorporated
294
+ into your certificate request.
295
+ What you are about to enter is what is called a Distinguished Name or a DN.
296
+ There are quite a few fields but you can leave some blank
297
+ For some fields there will be a default value,
298
+ If you enter '.', the field will be left blank.
299
+ -----
300
+ Country Name (2 letter code) [AU]:YOUR_COUNTRY
301
+ State or Province Name (full name) [Some-State]:YOUR_STATE
302
+ Locality Name (eg, city) []:YOUR_CITY
303
+ Organization Name (eg, company) [Internet Widgits Pty Ltd]:YOUR_COMPANY
304
+ Organizational Unit Name (eg, section) []:YOUR_UNIT
305
+ Common Name (eg, YOUR name) []:YOUR_DOMAINNAME_HERE
306
+ Email Address []:YOUR_EMAIL
307
+
308
+ Please enter the following 'extra' attributes
309
+ to be sent with your certificate request
310
+ A challenge password []:
311
+ An optional company name []:
312
+
313
+ ### Remove the Passphrase
314
+ We are almost finished creating the certificate. However, it would serve us to remove the passphrase. Although having the passphrase in place does provide heightened security, the issue starts when one tries to reload nginx. In the event that nginx crashes or needs to reboot, you will always have to re-enter your passphrase to get your entire web server back online.
315
+
316
+ Use these commands to remove the password:
317
+ :::term
318
+ $ cp server.key server.key.org
319
+ $ openssl rsa -in server.key.org -out server.key
320
+
321
+
322
+ ### Sign your SSL Certificate
323
+ Your certificate is all but done, and you just have to sign it.
324
+
325
+ Keep in mind that you can specify how long the certificate should remain valid by changing the 365 to the number of days you prefer. As it stands this certificate will expire after one year.
326
+ :::term
327
+ $ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
328
+ Signature ok
329
+ subject= ...
330
+ Getting Private key
331
+
332
+ ### Set Up the Certificate
333
+ Now we have all of the required components of the finished certificate.
334
+ The next thing to do is to set up the virtual host to serve your domain from HTTS connection.
335
+
336
+ Update existing Nginx `/opt/nginx/conf/conf.d/https_rhoconnect.conf` configuration file by including the newly signed certificate and private key:
337
+ :::term
338
+ upstream thin_cluster {
339
+ # ...
340
+ }
341
+
342
+ # HTTPS server
343
+ server {
344
+ listen 443;
345
+ server_name YOUR_DOMAINNAME_HERE;
346
+ root /opt/nginx/html/#{app_name}/public;
347
+
348
+ location / {
349
+ # ...
350
+ proxy_pass http://thin_cluster;
351
+ }
352
+
353
+ ssl on;
354
+ ssl_certificate /opt/nginx/ssl/server.crt;
355
+ ssl_certificate_key /opt/nginx/ssl/server.key;
356
+ }
357
+
358
+
359
+ ### Activate the Virtual Host
360
+ Restart nginx:
361
+ :::term
362
+ $ /etc/init.d/nginx restart
363
+
364
+ Now we're ready to access the above host using:
365
+ :::term
366
+ https://YOUR_DOMAINNAME_HERE
367
+
368
+
229
369
  ## Deploying RhoConnect Redis and Push packages on Linux servers
230
370
 
231
371
  ### RhoConnect Redis
232
372
 
233
- RhoConnect Redis is a packaged Redis server for RhoConnect development and production environment on Linux servers.
234
- <b>rhoconnect-redis</b> package might be useful if you want to deploy Redis on separate server.
373
+ RhoConnect Redis is a packaged Redis server for RhoConnect development and production environment on Linux servers.
374
+ <b>rhoconnect-redis</b> package might be useful if you want to deploy Redis on separate server.
235
375
 
236
376
  The package compiles from sources latest stable Redis release (2.4.15) and installs it to `/opt/rhoconnect` directory with the following settings:
237
377
 
@@ -285,13 +425,20 @@ You can start a redis server using the following command.
285
425
  $ sudo /etc/init.d/redis start
286
426
 
287
427
  ### RhoConnect Push Service
288
- You can create a RhoConnect Push production environment on Linux servers by installing prepackaged software for Ubuntu (12.x) and CentOS (6.x). In a few clicks, you will have installed on your Linux server.
428
+ You can create a RhoConnect Push production environment on Linux servers by installing prepackaged software for
429
+ Ubuntu (12.x) and CentOS (5.x/6.x). In a few clicks, you will have installed on your Linux server.
289
430
 
290
431
  * Node.js with Npm package manager
291
432
 
292
433
  * RhoConnect Push service
293
434
 
294
- * Upstart script to start, stop, and control Push service
435
+ * Upstart script to start, stop, and control Push service (for Ubuntu and CentOS 6.x)
436
+
437
+ * `/etc/init.d/rhoconnect-push` init script to start, stop, and restart Push service (CentOS 5.x)
438
+
439
+ Prerequisites:
440
+
441
+ * Python 2.6 or 2.7
295
442
 
296
443
  #### Steps for Debian-Based Linux Users
297
444
  Add the following line to the end of your /etc/apt/sources.list.
@@ -306,7 +453,16 @@ Then update the repo list and install RhoConnect Push.
306
453
  $ sudo apt-get install rhoconnect-push
307
454
 
308
455
  #### Steps for RedHat-Based Linux Users
309
- Create a file named rhoconnect-repo.repo in the /etc/yum.repos.d/ directory.
456
+ Node.js requires python 2.6 which is not available for CentOS 5 stock version.
457
+ For this flavor of linux you need to manually install EPEL repo and install python26 RPM out of it:
458
+
459
+ :::term
460
+ $ wget http://mirror.chpc.utah.edu/pub/epel/5/i386/epel-release-5-4.noarch.rpm
461
+ $ rpm -i epel-release-5-4.noarch.rpm
462
+ $ yum install python26
463
+
464
+
465
+ Now create a file named rhoconnect-repo.repo in the /etc/yum.repos.d/ directory.
310
466
 
311
467
  :::term
312
468
  $ sudo nano /etc/yum.repos.d/rhoconnect-repo.repo
@@ -332,55 +488,71 @@ and deploy it into the J2EE App Server.
332
488
  (see the corresponding 'rake' task for creating the WAR containers).
333
489
  Deploying the WAR container varies per J2EE App Server, for JBoss it is necessary
334
490
  to place the WAR file into the server's deploy directory.
335
-
336
- ## Deploying on Heroku Cedar
337
491
 
338
- #### Prerequisites
492
+ #### Deploying warbler package on Apache Tomcat web server
493
+ To successfully deploy warbler package on Tomcat you need to make rhoconnect app be the default app. There are a few ways to reach
494
+ this goal and we describe only a couple of them.
339
495
 
340
- * [Heroku account](https://api.heroku.com/login) and [Heroku Toolbelt](https://toolbelt.heroku.com/)
341
-
342
- * Rhoconnect gem version >= 3.2.0
496
+ ##### Method 1
343
497
 
344
- #### Create Rhoconnect application
345
- Create your Rhoconnect app and make sure that it's up and running in your development environment using thin:
498
+ 1) Stop Tomcat `shutdown.sh`
346
499
 
347
- :::term
348
- $ cd your_rhoconnect_app
349
- $ bundle exec thin start
500
+ 2) Delete the `ROOT` directory under `$CATALINA_BASE/webapps`
501
+
502
+ 3) Name your war file as `ROOT.war` (capitals mandatory)
503
+
504
+ 4) Drop the `ROOT.war` file directly in the `$CATALINA_BASE/webapps` directory
505
+
506
+ 5) Start Tomcat `startup.sh`
507
+
508
+ ##### Method 2
509
+
510
+ 1) Stop Tomcat
511
+
512
+ 2) Copy your war file in `$CATALINA_BASE/webapps`, under its original name
513
+
514
+ 3) Turn off autoDeploy and deployOnStartup in your Host element in the server.xml file.
515
+
516
+ 4) Explicitly define your application context in server.xml, specifying both path (must be empty!) and docBase.
350
517
 
351
- #### Declare `Procfile`
352
- This step is optional, but it will give you more control and flexibility when application deployed on Heroku.
353
- Create in your rhoconnect project file named `Procfile`:
518
+ :::xml
519
+ <Host name="localhost" appBase="webapps"
520
+ unpackWARs="true" autoDeploy="false" deployOnStartup="false">
521
+ <!-- ... -->
522
+ <Context docBase="your-app.war" path=""/>
523
+ <!-- ... -->
524
+ </Host>
525
+
526
+ 5) Start Tomcat
527
+
528
+ ## Deploying on Heroku
354
529
 
355
- :::term
356
- web: bundle exec thin start -p $PORT
530
+ #### Prerequisites
357
531
 
358
- If your application is using resque worker, then you should specify it in the `Procfile` as well:
532
+ * [Heroku account](https://api.heroku.com/login) and [Heroku Toolbelt](https://toolbelt.heroku.com/)
359
533
 
360
- :::term
361
- web: bundle exec thin start -p $PORT
362
- worker: bundle exec rake resque:work
534
+ * Rhoconnect version >= 3.4
363
535
 
364
- Now you can run your app locally:
536
+ #### Create Rhoconnect application
537
+ Create your Rhoconnect app and make sure that it's up and running in your development environment using thin:
365
538
 
366
- :::term
367
- $ gem install foreman
368
- $ foreman start
539
+ :::term
540
+ $ cd your_rhoconnect_app
541
+ $ bundle exec thin start
369
542
 
370
543
 
371
544
  #### Deploy to Heroku
372
- Before moving your code to Git you need comment in your project's `Gemfile` declaration of `sqlite3` gem, because target
373
- Heroku server has no development libraries required to build that gem.
545
+ Heroku uses git as its deployment interface. To create and deploy your application on Heroku, use the the following steps:
374
546
 
375
547
  :::term
376
548
  $ git init
377
549
  $ git add .
378
- $ git commit -m ' ... '
379
- $ heroku create --stack cedar
550
+ $ git commit -m 'initial commit'
551
+ $ heroku create
380
552
  $ heroku addons:add redistogo:nano
381
553
  $ git push heroku master
382
554
  $ heroku open
383
-
555
+
384
556
  #### Monitoring app on Heroku
385
557
  Use `heroku ps` to determine the number of processes that are executing.
386
558
  Use `heroku logs` to view an aggregated list of log messages from all process types.
@@ -388,15 +560,15 @@ Use `heroku logs` to view an aggregated list of log messages from all process ty
388
560
  :::term
389
561
  $ heroku ps
390
562
  $ heroku logs
391
-
563
+
392
564
  #### Get connected with Rhodes client
393
- If you have a rhodes client and wanted to sync it with rhoconnect app on Heroku, then set proper `syncserver` URL in `rhoconfig.txt` file:
565
+ If you have a rhodes client and want to sync it with your rhoconnect app on Heroku, then set the proper `syncserver` URL in `rhoconfig.txt`:
394
566
 
395
567
  :::term
396
- syncserver = 'http://<your-heroku-app-here>.herokuapp.com/application'
568
+ syncserver = 'https://<your-heroku-app-here>.herokuapp.com/application'
569
+
397
570
 
398
571
 
399
572
 
400
573
 
401
574
 
402
-
@@ -1,79 +1,62 @@
1
- Extending Rhoconnect Application with custom routes
1
+ Extending RhoConnect Application with custom routes
2
2
  ===
3
3
 
4
- Extending Rhoconnect Application with custom routes
5
- ---
6
-
7
- You can provide custom routes support in your Rhoconnect application while you still fully utilize the powerful features provided by the default Rhoconnect server implementation. To do this, create a custom server class inherited from `Rhoconnect::Server` and define all of your custom routes in this extended server class.
8
-
9
- The following example illustrates how to add a sample `my_custom_route' to the existing Rhoconnect application.
10
-
11
- 1) create `my_server.rb` class in your Rhoconnect application's root directory:
12
-
13
- :::ruby
14
- class MyServer < Rhoconnect::Server
15
- get '/my_custom_route' do
16
- if current_user
17
- send_file 'public/my_file.png'
18
- end
19
- nil
20
- end
21
- end
4
+ You can provide custom routes support in your RhoConnect application and utilize all the powerful features of the typical Sinatra app. To do this, simply define your routes in the corresponding controller class. Endpoint URL for your routes will be relative to the controller's root.
22
5
 
23
- The above custom route implementation will respond to client's GET request, verifies the current_user (which will be extracted from the Rhoconnect session cookie)
24
- and returns a static PNG file (which can be later used in BLOB syncs)
6
+ The following example illustrates how to add a sample `my_custom_route' to the Product Controller:
25
7
 
8
+ :::ruby
9
+ class Product < Rhoconnect::Controller::Base
10
+ get '/my_custom_route', :login_required => true do
11
+ send_file 'public/my_file.png'
12
+ end
13
+ end
26
14
 
27
- 2) Replace the default server instance with the new extended one in the `config.ru` file of your Rhoconnect application:
15
+ This route will have the following URL : GET '/app/v4/Product/my_custom_route'
28
16
 
29
- :::ruby
30
- # Setup the url map
31
- run Rack::URLMap.new \
32
- "/" => MyServer.new,
33
- "/resque" => Resque::Server.new, # If you don't want resque frontend, disable it here
34
- "/console" => RhoconnectConsole::Server.new # If you don't want rhoconnect frontend, disable it here
35
-
17
+ The above custom route implementation will respond to client's GET request, verifies the current_user (which will be extracted from the RHoConnect session cookie and checked for validity by the `:login_required` condition)
18
+ and returns a static PNG file (which can be later used in BLOB syncs)
36
19
 
37
20
  Using the New Custom route in BLOB syncs
38
21
  ---
39
22
 
40
- After you create the new custom routes and replace the default server instance with the new extended one, you can reference and use them from standard Rhodes applications.
23
+ After you create the new custom routes you can reference and use them from standard Rhodes applications.
41
24
  For example, suppose you have a Rhodes app with a Product model. To use a custom route in BLOB syncs, define the following property in the Rhodes Product model (file: `app/Product/product.rb`):
42
25
 
43
- :::ruby
44
- # The model has already been created by the framework, and extends Rhom::RhomObject
45
- # You can add more methods here
46
- class Product
47
- include Rhom::PropertyBag
26
+ :::ruby
27
+ # The model has already been created by the framework, and extends Rhom::RhomObject
28
+ # You can add more methods here
29
+ class Product
30
+ include Rhom::PropertyBag
48
31
 
49
- # Uncomment the following line to enable sync with Product.
50
- enable :sync
32
+ # Uncomment the following line to enable sync with Product.
33
+ enable :sync
51
34
 
52
- #add model specific code here
53
- property :my_custom_blob_field, :blob, :overwrite
54
- end
55
-
35
+ #add model specific code here
36
+ property :my_custom_blob_field, :blob, :overwrite
37
+ end
38
+
56
39
  To see the static image, modify the `app/Product/show.erb` file for the Product model in your Rhodes application:
57
40
 
58
- :::html
59
- <li>
60
- <div class="itemLabel">My Static Field Image</div>
61
- <div class="itemValue"><img src="<%=Rho::RhoApplication::get_blob_path(@product.my_custom_field)%>"></img></div>
41
+ :::html
42
+ <li>
43
+ <div class="itemLabel">My Static Field Image</div>
44
+ <div class="itemValue"><img src="<%=Rho::RhoApplication::get_blob_path(@product.my_custom_field)%>"></img></div>
62
45
  </li>
63
-
64
- Then, modify your Rhoconnect source adapter (in `rhoconnect_app/sources/product.rb`) to provide BLOB's url for the `my_custom_blob_field`:
46
+
47
+ Then, modify your RhoConnect source adapter model (in `rhoconnect_app/models/ruby/product.rb`) to provide BLOB's url for the `my_custom_blob_field`:
65
48
 
66
- :::ruby
67
- def query(params=nil)
68
- parsed = JSON.parse(RestClient.get("#{@base}.json").body)
49
+ :::ruby
50
+ def query(params=nil)
51
+ parsed = JSON.parse(RestClient.get("#{@base}.json").body)
69
52
 
70
- @result={}
71
- parsed.each do |item|
72
- item["product"]["my_custom_field-rhoblob"] = "http://localhost:9292/my_custom_route"
73
- @result[item["product"]["id"].to_s] = item["product"]
74
- end if parsed
75
- end
53
+ @result={}
54
+ parsed.each do |item|
55
+ item["product"]["my_custom_field-rhoblob"] = "http://localhost:9292/app/v4/Product/my_custom_route"
56
+ @result[item["product"]["id"].to_s] = item["product"]
57
+ end if parsed
58
+ end
76
59
 
77
- This way, your `my_custom_field` would be getting the BLOB image data from the custom route defined in your Rhoconnect extension server.
60
+ This way, your `my_custom_field` would be getting the BLOB image data from the custom route defined in your RhoConnect Source Adapter Controller.
78
61
 
79
62
  For more information on BLOB syncs, see [this section](http://docs.rhomobile.com/rhoconnect/blob-sync).
data/doc/heroku-addon.txt CHANGED
@@ -1,3 +1,5 @@
1
+ # RhoConnect Heroku Addon
2
+
1
3
  RhoConnect is a data synchronization server and client library that keeps enterprise app data current and available on users’ mobile devices.
2
4
 
3
5
  The information is stored locally on a user’s device, and is available even when disconnected and offline.