rhoconnect 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +208 -0
- data/CREDITS +38 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +97 -0
- data/LICENSE +75 -0
- data/README.md +10 -0
- data/Rakefile +82 -0
- data/bench/bench +7 -0
- data/bench/bench_runner.rb +112 -0
- data/bench/benchapp/Gemfile +21 -0
- data/bench/benchapp/Gemfile.lock +76 -0
- data/bench/benchapp/Rakefile +22 -0
- data/bench/benchapp/application.rb +39 -0
- data/bench/benchapp/config.ru +36 -0
- data/bench/benchapp/settings/license.key +1 -0
- data/bench/benchapp/settings/settings.yml +20 -0
- data/bench/benchapp/sources/mock_adapter.rb +55 -0
- data/bench/benchapp/sources/queue_mock_adapter.rb +2 -0
- data/bench/benchapp/spec/sources/mock_adapter_spec.rb +25 -0
- data/bench/benchapp/spec/sources/queue_mock_adapter_spec.rb +25 -0
- data/bench/benchapp/spec/spec_helper.rb +42 -0
- data/bench/blobapp/Gemfile +31 -0
- data/bench/blobapp/Gemfile.lock +103 -0
- data/bench/blobapp/Rakefile +25 -0
- data/bench/blobapp/application.rb +44 -0
- data/bench/blobapp/config.ru +36 -0
- data/bench/blobapp/settings/license.key +1 -0
- data/bench/blobapp/settings/settings.yml +16 -0
- data/bench/blobapp/sources/blob_adapter.rb +71 -0
- data/bench/blobapp/spec/sources/blob_adapter_spec.rb +25 -0
- data/bench/blobapp/spec/spec_helper.rb +42 -0
- data/bench/lib/bench/cli.rb +16 -0
- data/bench/lib/bench/logging.rb +13 -0
- data/bench/lib/bench/mock_client.rb +41 -0
- data/bench/lib/bench/result.rb +50 -0
- data/bench/lib/bench/runner.rb +107 -0
- data/bench/lib/bench/session.rb +67 -0
- data/bench/lib/bench/statistics.rb +56 -0
- data/bench/lib/bench/test_data.rb +98 -0
- data/bench/lib/bench/timer.rb +10 -0
- data/bench/lib/bench/utils.rb +49 -0
- data/bench/lib/bench.rb +129 -0
- data/bench/lib/testdata/100-data.txt +148 -0
- data/bench/lib/testdata/5-data.txt +9 -0
- data/bench/lib/testdata/images/icon.ico +0 -0
- data/bench/lib/testdata/images/icon.png +0 -0
- data/bench/lib/testdata/images/loading-Landscape.png +0 -0
- data/bench/lib/testdata/images/loading-LandscapeLeft.png +0 -0
- data/bench/lib/testdata/images/loading-LandscapeRight.png +0 -0
- data/bench/lib/testdata/images/loading-Portrait.png +0 -0
- data/bench/lib/testdata/images/loading-PortraitUpsideDown.png +0 -0
- data/bench/lib/testdata/images/loading.png +0 -0
- data/bench/lib/testdata/images/loading@2x.png +0 -0
- data/bench/run_bench.sh +42 -0
- data/bench/run_blob_script.sh +3 -0
- data/bench/run_cud_script.sh +3 -0
- data/bench/run_query_md_script.sh +3 -0
- data/bench/run_query_only_script.sh +3 -0
- data/bench/run_query_script.sh +3 -0
- data/bench/scripts/blob_cud_script.rb +98 -0
- data/bench/scripts/cud_script.rb +92 -0
- data/bench/scripts/helpers.rb +101 -0
- data/bench/scripts/query_md_script.rb +45 -0
- data/bench/scripts/query_only_script.rb +51 -0
- data/bench/scripts/query_script.rb +45 -0
- data/bench/spec/bench_spec_helper.rb +33 -0
- data/bench/spec/logging_spec.rb +15 -0
- data/bench/spec/mock_adapter_spec.rb +61 -0
- data/bench/spec/mock_client_spec.rb +65 -0
- data/bench/spec/result_spec.rb +61 -0
- data/bench/spec/utils_spec.rb +36 -0
- data/bin/rhoconnect +34 -0
- data/bin/rhoconnect-setup +84 -0
- data/doc/async-jobs.txt +69 -0
- data/doc/authentication.txt +76 -0
- data/doc/benchmarks.txt +168 -0
- data/doc/blob-sync.txt +130 -0
- data/doc/bulk-sync.txt +102 -0
- data/doc/client.txt +432 -0
- data/doc/command-line.txt +210 -0
- data/doc/contributing.txt +60 -0
- data/doc/deploying.txt +82 -0
- data/doc/install.txt +28 -0
- data/doc/introduction.txt +20 -0
- data/doc/licensing.txt +18 -0
- data/doc/metadata.txt +458 -0
- data/doc/migration.txt +182 -0
- data/doc/public/css/print.css +29 -0
- data/doc/public/css/screen.css +257 -0
- data/doc/public/css/style.css +20 -0
- data/doc/push.txt +135 -0
- data/doc/release.txt +41 -0
- data/doc/rest-api.txt +367 -0
- data/doc/source-adapters.txt +325 -0
- data/doc/stats-middleware.txt +69 -0
- data/doc/testing.txt +222 -0
- data/doc/tutorial.txt +315 -0
- data/doc/web-console.txt +35 -0
- data/examples/simple/Rakefile +14 -0
- data/examples/simple/application.rb +27 -0
- data/examples/simple/config.ru +49 -0
- data/examples/simple/settings/license.key +1 -0
- data/examples/simple/settings/settings.yml +23 -0
- data/examples/simple/sources/sample_adapter.rb +5 -0
- data/examples/simple/sources/simple_adapter.rb +5 -0
- data/generators/rhoconnect.rb +119 -0
- data/generators/templates/application/Gemfile +21 -0
- data/generators/templates/application/Rakefile +22 -0
- data/generators/templates/application/application.rb +39 -0
- data/generators/templates/application/config.ru +36 -0
- data/generators/templates/application/settings/license.key +1 -0
- data/generators/templates/application/settings/settings.yml +14 -0
- data/generators/templates/application/spec/spec_helper.rb +42 -0
- data/generators/templates/source/source_adapter.rb +47 -0
- data/generators/templates/source/source_spec.rb +25 -0
- data/install.sh +408 -0
- data/installer/unix-like/rho_connect_install_checkers.rb +140 -0
- data/installer/unix-like/rho_connect_install_constants.rb +51 -0
- data/installer/unix-like/rho_connect_install_debian.rb +63 -0
- data/installer/unix-like/rho_connect_install_dnd.rb +58 -0
- data/installer/unix-like/rho_connect_install_get_params.rb +30 -0
- data/installer/unix-like/rho_connect_install_installers.rb +142 -0
- data/installer/unix-like/rho_connect_install_utilities.rb +85 -0
- data/installer/unix-like/rho_connect_install_yum.rb +63 -0
- data/installer/unix-like/rhoinstaller.rb +89 -0
- data/installer/utils/create_texts.rb +366 -0
- data/installer/utils/install_test.rb +140 -0
- data/installer/windows/EnvVarUpdate.nsh +328 -0
- data/installer/windows/ServiceLib.nsh +369 -0
- data/installer/windows/configUi.ini +44 -0
- data/installer/windows/icon.ico +0 -0
- data/installer/windows/rhosync.nsi +418 -0
- data/installer/windows/uninstall.bat +7 -0
- data/lib/rhoconnect/api/admin/get_api_token.rb +14 -0
- data/lib/rhoconnect/api/admin/get_license_info.rb +8 -0
- data/lib/rhoconnect/api/admin/login.rb +6 -0
- data/lib/rhoconnect/api/admin/reset.rb +10 -0
- data/lib/rhoconnect/api/admin/stats.rb +21 -0
- data/lib/rhoconnect/api/application/bulk_data.rb +7 -0
- data/lib/rhoconnect/api/application/clientcreate.rb +8 -0
- data/lib/rhoconnect/api/application/clientlogin.rb +6 -0
- data/lib/rhoconnect/api/application/clientregister.rb +6 -0
- data/lib/rhoconnect/api/application/clientreset.rb +6 -0
- data/lib/rhoconnect/api/application/query.rb +7 -0
- data/lib/rhoconnect/api/application/queue_updates.rb +6 -0
- data/lib/rhoconnect/api/application/search.rb +6 -0
- data/lib/rhoconnect/api/client/create_client.rb +3 -0
- data/lib/rhoconnect/api/client/delete_client.rb +5 -0
- data/lib/rhoconnect/api/client/get_client_params.rb +3 -0
- data/lib/rhoconnect/api/client/list_client_docs.rb +12 -0
- data/lib/rhoconnect/api/client/list_clients.rb +3 -0
- data/lib/rhoconnect/api/client/ping.rb +7 -0
- data/lib/rhoconnect/api/source/get_adapter.rb +3 -0
- data/lib/rhoconnect/api/source/get_db_doc.rb +7 -0
- data/lib/rhoconnect/api/source/get_source_params.rb +3 -0
- data/lib/rhoconnect/api/source/list_source_docs.rb +10 -0
- data/lib/rhoconnect/api/source/list_sources.rb +15 -0
- data/lib/rhoconnect/api/source/push_deletes.rb +8 -0
- data/lib/rhoconnect/api/source/push_objects.rb +8 -0
- data/lib/rhoconnect/api/source/save_adapter.rb +3 -0
- data/lib/rhoconnect/api/source/set_db_doc.rb +8 -0
- data/lib/rhoconnect/api/source/set_refresh_time.rb +8 -0
- data/lib/rhoconnect/api/source/upload_file.rb +4 -0
- data/lib/rhoconnect/api/user/create_user.rb +7 -0
- data/lib/rhoconnect/api/user/delete_user.rb +9 -0
- data/lib/rhoconnect/api/user/list_users.rb +3 -0
- data/lib/rhoconnect/api/user/update_user.rb +4 -0
- data/lib/rhoconnect/api_token.rb +19 -0
- data/lib/rhoconnect/app.rb +76 -0
- data/lib/rhoconnect/bulk_data/bulk_data.rb +88 -0
- data/lib/rhoconnect/bulk_data/syncdb.index.schema +4 -0
- data/lib/rhoconnect/bulk_data/syncdb.schema +41 -0
- data/lib/rhoconnect/bulk_data.rb +2 -0
- data/lib/rhoconnect/client.rb +96 -0
- data/lib/rhoconnect/client_sync.rb +412 -0
- data/lib/rhoconnect/console/app/helpers/auth_helper.rb +22 -0
- data/lib/rhoconnect/console/app/helpers/extensions.rb +19 -0
- data/lib/rhoconnect/console/app/helpers/helpers.rb +57 -0
- data/lib/rhoconnect/console/app/public/ThickBox.css +649 -0
- data/lib/rhoconnect/console/app/public/home.css +438 -0
- data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
- data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/rhomobile_rhohub_logo.png +0 -0
- data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
- data/lib/rhoconnect/console/app/public/jqplot/excanvas.min.js +35 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.cursor.js +952 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
- data/lib/rhoconnect/console/app/public/main.css +7 -0
- data/lib/rhoconnect/console/app/public/reset.css +76 -0
- data/lib/rhoconnect/console/app/public/style.css +2201 -0
- data/lib/rhoconnect/console/app/public/text.txt +0 -0
- data/lib/rhoconnect/console/app/routes/adapter.rb +28 -0
- data/lib/rhoconnect/console/app/routes/auth.rb +29 -0
- data/lib/rhoconnect/console/app/routes/client.rb +31 -0
- data/lib/rhoconnect/console/app/routes/docs.rb +145 -0
- data/lib/rhoconnect/console/app/routes/heroku.rb +19 -0
- data/lib/rhoconnect/console/app/routes/home.rb +63 -0
- data/lib/rhoconnect/console/app/routes/timing.rb +242 -0
- data/lib/rhoconnect/console/app/routes/user.rb +117 -0
- data/lib/rhoconnect/console/app/views/adapter.erb +16 -0
- data/lib/rhoconnect/console/app/views/client.erb +30 -0
- data/lib/rhoconnect/console/app/views/content.erb +14 -0
- data/lib/rhoconnect/console/app/views/doc.erb +8 -0
- data/lib/rhoconnect/console/app/views/docdata.erb +28 -0
- data/lib/rhoconnect/console/app/views/docs.erb +30 -0
- data/lib/rhoconnect/console/app/views/edituser.erb +13 -0
- data/lib/rhoconnect/console/app/views/headermenu.erb +40 -0
- data/lib/rhoconnect/console/app/views/home.erb +24 -0
- data/lib/rhoconnect/console/app/views/index.erb +58 -0
- data/lib/rhoconnect/console/app/views/jqplot.erb +52 -0
- data/lib/rhoconnect/console/app/views/layout.erb +165 -0
- data/lib/rhoconnect/console/app/views/login.erb +26 -0
- data/lib/rhoconnect/console/app/views/newuser.erb +17 -0
- data/lib/rhoconnect/console/app/views/ping.erb +28 -0
- data/lib/rhoconnect/console/app/views/result.erb +11 -0
- data/lib/rhoconnect/console/app/views/rightboxlinks.erb +15 -0
- data/lib/rhoconnect/console/app/views/select_doc.erb +17 -0
- data/lib/rhoconnect/console/app/views/upload_doc.erb +23 -0
- data/lib/rhoconnect/console/app/views/user.erb +29 -0
- data/lib/rhoconnect/console/app/views/users.erb +12 -0
- data/lib/rhoconnect/console/rhoconnect_api.rb +245 -0
- data/lib/rhoconnect/console/server.rb +32 -0
- data/lib/rhoconnect/console.rb +3 -0
- data/lib/rhoconnect/cors.rb +229 -0
- data/lib/rhoconnect/credential.rb +9 -0
- data/lib/rhoconnect/db_adapter.rb +46 -0
- data/lib/rhoconnect/document.rb +49 -0
- data/lib/rhoconnect/dynamic_adapter.rb +91 -0
- data/lib/rhoconnect/generator.rb +1 -0
- data/lib/rhoconnect/jobs/bulk_data_job.rb +203 -0
- data/lib/rhoconnect/jobs/ping_job.rb +46 -0
- data/lib/rhoconnect/jobs/source_job.rb +16 -0
- data/lib/rhoconnect/license.rb +86 -0
- data/lib/rhoconnect/lock_ops.rb +11 -0
- data/lib/rhoconnect/model.rb +414 -0
- data/lib/rhoconnect/ping/android.rb +56 -0
- data/lib/rhoconnect/ping/apple.rb +52 -0
- data/lib/rhoconnect/ping/blackberry.rb +56 -0
- data/lib/rhoconnect/ping.rb +3 -0
- data/lib/rhoconnect/read_state.rb +31 -0
- data/lib/rhoconnect/rho_indifferent_access.rb +88 -0
- data/lib/rhoconnect/server/views/index.erb +13 -0
- data/lib/rhoconnect/server.rb +286 -0
- data/lib/rhoconnect/source.rb +289 -0
- data/lib/rhoconnect/source_adapter.rb +123 -0
- data/lib/rhoconnect/source_sync.rb +302 -0
- data/lib/rhoconnect/stats/middleware.rb +20 -0
- data/lib/rhoconnect/stats/record.rb +108 -0
- data/lib/rhoconnect/store.rb +232 -0
- data/lib/rhoconnect/tasks.rb +350 -0
- data/lib/rhoconnect/test_methods.rb +220 -0
- data/lib/rhoconnect/user.rb +95 -0
- data/lib/rhoconnect/version.rb +3 -0
- data/lib/rhoconnect/x_domain_session_wrapper.rb +53 -0
- data/lib/rhoconnect.rb +285 -0
- data/rhoconnect.gemspec +67 -0
- data/spec/api/admin/api_token_spec.rb +14 -0
- data/spec/api/admin/get_api_token_spec.rb +36 -0
- data/spec/api/admin/get_license_info_spec.rb +38 -0
- data/spec/api/admin/reset_spec.rb +22 -0
- data/spec/api/admin/stats_spec.rb +66 -0
- data/spec/api/api_helper.rb +21 -0
- data/spec/api/application/rhoconnect_api_spec.rb +548 -0
- data/spec/api/client/create_client_spec.rb +13 -0
- data/spec/api/client/delete_client_spec.rb +13 -0
- data/spec/api/client/get_client_params_spec.rb +18 -0
- data/spec/api/client/list_client_docs_spec.rb +32 -0
- data/spec/api/client/list_clients_spec.rb +22 -0
- data/spec/api/client/ping_spec.rb +23 -0
- data/spec/api/rhosync_api_spec.rb.orig +606 -0
- data/spec/api/source/adapter_spec.rb +29 -0
- data/spec/api/source/get_db_doc_spec.rb +21 -0
- data/spec/api/source/get_source_params_spec.rb +32 -0
- data/spec/api/source/list_source_docs_spec.rb +25 -0
- data/spec/api/source/list_sources_spec.rb +26 -0
- data/spec/api/source/push_deletes_spec.rb +18 -0
- data/spec/api/source/push_objects_spec.rb +27 -0
- data/spec/api/source/set_db_doc_spec.rb +19 -0
- data/spec/api/source/set_refresh_time_spec.rb +43 -0
- data/spec/api/source/upload_file_spec.rb +26 -0
- data/spec/api/user/create_user_spec.rb +16 -0
- data/spec/api/user/delete_user_spec.rb +36 -0
- data/spec/api/user/list_users_spec.rb +30 -0
- data/spec/api/user/update_user_spec.rb +31 -0
- data/spec/api_token_spec.rb +14 -0
- data/spec/app_spec.rb +18 -0
- data/spec/apps/emptyapp/application.rb +27 -0
- data/spec/apps/emptyapp/settings/license.key +1 -0
- data/spec/apps/emptyapp/settings/settings.yml +14 -0
- data/spec/apps/rhotestapp/Rakefile +1 -0
- data/spec/apps/rhotestapp/application.rb +19 -0
- data/spec/apps/rhotestapp/config.ru +1 -0
- data/spec/apps/rhotestapp/settings/apple_fake_cert.pem +1 -0
- data/spec/apps/rhotestapp/settings/license.key +1 -0
- data/spec/apps/rhotestapp/settings/settings.yml +36 -0
- data/spec/apps/rhotestapp/sources/base_adapter.rb +9 -0
- data/spec/apps/rhotestapp/sources/fixed_schema_adapter.rb +28 -0
- data/spec/apps/rhotestapp/sources/sample_adapter.rb +71 -0
- data/spec/apps/rhotestapp/sources/simple_adapter.rb +41 -0
- data/spec/apps/rhotestapp/sources/sub_adapter.rb +7 -0
- data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem/mygem.rb +8 -0
- data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem.rb +1 -0
- data/spec/bulk_data/bulk_data_spec.rb +97 -0
- data/spec/client_spec.rb +124 -0
- data/spec/client_sync_spec.rb +774 -0
- data/spec/doc/base.html +72 -0
- data/spec/doc/doc_spec.rb +376 -0
- data/spec/doc/footer.html +4 -0
- data/spec/doc/header.html +30 -0
- data/spec/document_spec.rb +31 -0
- data/spec/dynamic_adapter_spec.rb +43 -0
- data/spec/factories/factories.rb +17 -0
- data/spec/generator/generator_spec.rb +58 -0
- data/spec/generator/generator_spec_helper.rb +9 -0
- data/spec/jobs/bulk_data_job_spec.rb +125 -0
- data/spec/jobs/ping_job_spec.rb +102 -0
- data/spec/jobs/source_job_spec.rb +29 -0
- data/spec/license_spec.rb +66 -0
- data/spec/model_spec.rb +273 -0
- data/spec/perf/bulk_data_perf_spec.rb +32 -0
- data/spec/perf/perf_spec_helper.rb +50 -0
- data/spec/perf/store_perf_spec.rb +27 -0
- data/spec/ping/android_spec.rb +91 -0
- data/spec/ping/apple_spec.rb +70 -0
- data/spec/ping/blackberry_spec.rb +62 -0
- data/spec/read_state_spec.rb +35 -0
- data/spec/rhosync_spec.rb +75 -0
- data/spec/server/cors_spec.rb +287 -0
- data/spec/server/server_spec.rb +470 -0
- data/spec/server/x_domain_session_wrapper_spec.rb +150 -0
- data/spec/source_adapter_spec.rb +125 -0
- data/spec/source_spec.rb +114 -0
- data/spec/source_sync_spec.rb +328 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +231 -0
- data/spec/stats/middleware_spec.rb +53 -0
- data/spec/stats/record_spec.rb +92 -0
- data/spec/store_spec.rb +251 -0
- data/spec/support/shared_examples.rb +168 -0
- data/spec/sync_states_spec.rb +72 -0
- data/spec/test_methods_spec.rb +134 -0
- data/spec/testdata/1000-data.txt +1414 -0
- data/spec/testdata/compressed/compress-data.txt +1 -0
- data/spec/testdata/upload1.txt +1 -0
- data/spec/testdata/upload2.txt +1 -0
- data/spec/user_spec.rb +139 -0
- data/tasks/redis.rake +206 -0
- metadata +706 -0
@@ -0,0 +1,366 @@
|
|
1
|
+
$:.unshift File.expand_path(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
|
7
|
+
optparse = OptionParser.new do |opts|
|
8
|
+
options[:dist] = nil
|
9
|
+
opts.on( '-d', '--dist DISTRO', 'Specify DISTRO as the current distribution.' ) do |dist|
|
10
|
+
options[:dist] = dist
|
11
|
+
end #do
|
12
|
+
|
13
|
+
options[:prefix] = '/opt/rhoconnect/'
|
14
|
+
opts.on( '-p', '--prefix RHODIR', 'Specify RHODIR as the prefix directory.' ) do |dir|
|
15
|
+
options[:prefix] = dir
|
16
|
+
end #do
|
17
|
+
|
18
|
+
options[:redis] = true
|
19
|
+
opts.on( '--no-redis', '', 'Skip installing the redis server.' ) do
|
20
|
+
options[:redis] = false
|
21
|
+
end #do
|
22
|
+
|
23
|
+
options[:rubyVersion] = 'rubyee'
|
24
|
+
opts.on( '-r', '--rubyVer VERSION', 'Specify VERSION as the verion of ruby that is installed.' ) do |rubyVer|
|
25
|
+
options[:rubyVersion] = rubyVer
|
26
|
+
end #do
|
27
|
+
end #do
|
28
|
+
|
29
|
+
optparse.parse!
|
30
|
+
|
31
|
+
@prefix = options[:prefix]
|
32
|
+
@dist = options[:dist]
|
33
|
+
@redis = options[:redis]
|
34
|
+
@ruby_version = options[:rubyVersion]
|
35
|
+
@profile = (@dist == 'debian') ? '~/.profile' : '~/.bash_profile'
|
36
|
+
|
37
|
+
# create_redis_init
|
38
|
+
# Creates the redis initialization file and places it into the correct directory
|
39
|
+
def create_redis_init
|
40
|
+
redisInit="/etc/init.d/redis"
|
41
|
+
|
42
|
+
redis_init_script = <<'_REDIS_INIT_SCRIPT_'
|
43
|
+
#!/usr/bin/env bash
|
44
|
+
### BEGIN INIT INFO
|
45
|
+
# Provides: redis-server
|
46
|
+
# Required-Start: $syslog
|
47
|
+
# Required-Stop: $syslog
|
48
|
+
# Should-Start: $local_fs
|
49
|
+
# Should-Stop: $local_fs
|
50
|
+
# Default-Start: 2 3 4 5
|
51
|
+
# Default-Stop: 0 1 6
|
52
|
+
# Short-Description: redis-server - Persistent key-value db
|
53
|
+
# Description: redis-server - Persistent key-value db
|
54
|
+
### END INIT INFO
|
55
|
+
#
|
56
|
+
# Author: Wayne E. Seguin <wayneeseguin@gmail.com>
|
57
|
+
# License: The same licence as Redis, New BSD
|
58
|
+
# http://www.opensource.org/licenses/bsd-license.php
|
59
|
+
#
|
60
|
+
|
61
|
+
# Source the system config file, if it exists.
|
62
|
+
if [[ -s /etc/conf.d/redis ]] ; then
|
63
|
+
source /etc/conf.d/redis
|
64
|
+
fi
|
65
|
+
|
66
|
+
# Default config variables that have not been set.
|
67
|
+
port="${port:-6379}"
|
68
|
+
prefix="${prefix:-/opt/rhoconnect}"
|
69
|
+
redis="${prefix}bin/redis-server"
|
70
|
+
redis_cli="${prefix}bin/redis-cli"
|
71
|
+
pidfile="${pidfile:-/var/run/redis.pid}"
|
72
|
+
config="${config:-/opt/rhoconnect/etc/redis.conf}"
|
73
|
+
user="${user:-root}"
|
74
|
+
#prefix="${prefix:-/usr/local}"
|
75
|
+
#config="${config:-/usr/local/etc/redis.conf}"
|
76
|
+
#pidfile="${pidfile:-/var/run/redis/redis.pid}"
|
77
|
+
#config="${config:-/etc/redis/redis.conf}"
|
78
|
+
#user="${user:-redis}"
|
79
|
+
|
80
|
+
#
|
81
|
+
# Set the running $pid value based on $pidfile.
|
82
|
+
#
|
83
|
+
if [[ -s "$pidfile" ]] ; then
|
84
|
+
pid=$(cat $pidfile)
|
85
|
+
else
|
86
|
+
rm -f $pidfile
|
87
|
+
fi
|
88
|
+
|
89
|
+
# In case there was pidfile corruption...
|
90
|
+
if [[ "Linux" = "$(uname)" ]] ; then
|
91
|
+
# /proc does not exist on say, Darwin
|
92
|
+
if [[ ! -z "${pid}" ]] && [[ ! -x "/proc/${pid}" ]] ;then
|
93
|
+
pid="$(ps auxww | grep [r]edis | grep "$config" | grep -v 'grep' | awk '{print $2}')"
|
94
|
+
elif [[ -z "${pid}" ]] ; then
|
95
|
+
pid="$(ps auxww | grep [r]edis | grep "$config" | grep -v 'grep' | awk '{print $2}')"
|
96
|
+
fi
|
97
|
+
else
|
98
|
+
if [[ -z "${pid}" ]] ; then
|
99
|
+
pid="$(ps auxww | grep [r]edis | grep "$config" | grep -v 'grep' | awk '{print $2}')"
|
100
|
+
fi
|
101
|
+
fi
|
102
|
+
|
103
|
+
#
|
104
|
+
# Start redis using redis-server as user 'redis'.
|
105
|
+
#
|
106
|
+
redis_start() {
|
107
|
+
if [[ -f $pidfile ]] ; then
|
108
|
+
echo "$pidfile exists, redis-server is either already running or crashed."
|
109
|
+
exit 1
|
110
|
+
elif [[ ! -z "$pid" ]] ; then
|
111
|
+
echo -e "\nRedis is already running with configuration '$config'."
|
112
|
+
echo "$pid" > $pidfile # Ensure pidfile exists with the pid.
|
113
|
+
else
|
114
|
+
echo "Starting Redis server..."
|
115
|
+
su $user -c "$redis $config"
|
116
|
+
exit 0
|
117
|
+
fi
|
118
|
+
}
|
119
|
+
|
120
|
+
#
|
121
|
+
# Stop redis using redis-cli SHUTDOWN.
|
122
|
+
#
|
123
|
+
redis_stop() {
|
124
|
+
echo -n "Stopping redis server on port ${port} ... "
|
125
|
+
"$redis_cli" -p ${port} SHUTDOWN
|
126
|
+
|
127
|
+
# Keep user informed while server shuts down.
|
128
|
+
echo "Waiting for the redis server to shutdown "
|
129
|
+
|
130
|
+
if [[ "Linux" = "$(uname)" ]] ; then
|
131
|
+
if [[ "${pid}" = "" ]] ; then
|
132
|
+
echo "redis server is not running."
|
133
|
+
# Clear out the old pidfile if available
|
134
|
+
rm -f $pidfile
|
135
|
+
exit 1
|
136
|
+
fi
|
137
|
+
while [[ -x /proc/${pid} ]] ; do
|
138
|
+
echo -n '.' ; sleep 1
|
139
|
+
done
|
140
|
+
else # Darwin, etc...
|
141
|
+
while [[ ! -z "$(ps auxww | grep [r]edis | grep "$config" | awk '{print $2}')" ]] ; do
|
142
|
+
echo -n '.' ; sleep 1
|
143
|
+
done
|
144
|
+
fi
|
145
|
+
|
146
|
+
# Clear out the old pidfile.
|
147
|
+
rm -f $pidfile
|
148
|
+
|
149
|
+
# Notify user of successful completion.
|
150
|
+
echo -e "redis server stopped."
|
151
|
+
exit 0
|
152
|
+
}
|
153
|
+
|
154
|
+
redis_usage() {
|
155
|
+
echo -e "Usage: $0 {start,stop}"
|
156
|
+
exit 1
|
157
|
+
}
|
158
|
+
|
159
|
+
#
|
160
|
+
# CLI logic.
|
161
|
+
#
|
162
|
+
case "$1" in
|
163
|
+
start) redis_start ;;
|
164
|
+
stop) redis_stop ;;
|
165
|
+
*) redis_usage ;;
|
166
|
+
esac
|
167
|
+
_REDIS_INIT_SCRIPT_
|
168
|
+
|
169
|
+
File.open(redisInit, 'w') { |f| f << redis_init_script }
|
170
|
+
# Make the init script executable
|
171
|
+
`chmod +x #{redisInit}`
|
172
|
+
|
173
|
+
# Set run levels
|
174
|
+
if @dist == 'debian'
|
175
|
+
`update-rc.d -f redis defaults`
|
176
|
+
else
|
177
|
+
`/sbin/chkconfig redis on`
|
178
|
+
# `/sbin/chkconfig --list redis`
|
179
|
+
end
|
180
|
+
|
181
|
+
redis_init_script
|
182
|
+
end #create_redis_init
|
183
|
+
|
184
|
+
def create_redis_logrotate
|
185
|
+
redis_logrotate_conf = <<'_REDIS_LOGRORATE_CONF_'
|
186
|
+
/var/log/redis.log {
|
187
|
+
rotate 3
|
188
|
+
missingok
|
189
|
+
notifempty
|
190
|
+
size 250k
|
191
|
+
create 0644 root root
|
192
|
+
compress
|
193
|
+
}
|
194
|
+
_REDIS_LOGRORATE_CONF_
|
195
|
+
|
196
|
+
File.open('/etc/logrotate.d/redis', 'w') { |f| f << redis_logrotate_conf }
|
197
|
+
end
|
198
|
+
|
199
|
+
# generate_common_info
|
200
|
+
# Generates the readme info that is common across all distributions
|
201
|
+
def generate_common_info
|
202
|
+
|
203
|
+
readme = <<_README_
|
204
|
+
Thank you for choosing Rhomobile for your cross-platform app needs!
|
205
|
+
To finish this setup, please complete the following...
|
206
|
+
|
207
|
+
1) Add necessary bins to the path(s) of the users who will
|
208
|
+
be using this software. You may also wish to add these items
|
209
|
+
to your #{@profile} to automatically add them upon login.
|
210
|
+
Ex:
|
211
|
+
|
212
|
+
A) All bins in the main bin deposit:
|
213
|
+
export PATH=#{@prefix}bin:$PATH
|
214
|
+
|
215
|
+
B) Bins specifically placed in the ruby/bin directory
|
216
|
+
export PATH=#{@prefix}ruby/1.8/bin:$PATH
|
217
|
+
|
218
|
+
Or if you had other versions of ruby installed previously to running
|
219
|
+
this installation, you may instead wish to simply create an alias
|
220
|
+
for the newly installed ruby.
|
221
|
+
|
222
|
+
Ex:
|
223
|
+
|
224
|
+
alias #{@ruby_version}=#{@prefix}bin/ruby
|
225
|
+
|
226
|
+
B) Add the export line to #{@profile}:
|
227
|
+
|
228
|
+
export PATH=#{@prefix}bin:#{@prefix}ruby/bin:$PATH
|
229
|
+
|
230
|
+
C) Add #{@prefix}lib to your library path like so:
|
231
|
+
|
232
|
+
export LD_LIBRARY_PATH=#{@prefix}lib:$LD_LIBRARY_PATH
|
233
|
+
Note: You may also want to add this line to #{@profile}
|
234
|
+
|
235
|
+
2) Rhoconnect installer configured redis server with the following settings:
|
236
|
+
|
237
|
+
A) redis.conf file is located in #{@prefix}etc/ directory with properties:
|
238
|
+
daemonize yes
|
239
|
+
pidfile /var/run/redis.pid
|
240
|
+
logfile /var/log/redis.log
|
241
|
+
|
242
|
+
B) Redis logrotate settings for /var/log/redis.log files defined in '/etc/logrotate.d/redis':
|
243
|
+
|
244
|
+
/var/log/redis.log {
|
245
|
+
rotate 3
|
246
|
+
missingok
|
247
|
+
notifempty
|
248
|
+
size 250k
|
249
|
+
create 0644 root root
|
250
|
+
compress
|
251
|
+
}
|
252
|
+
|
253
|
+
C) Redis start-up script '/etc/init.d/redis'.
|
254
|
+
You can start/stop redis server by running the following commands:
|
255
|
+
/etc/init.d/redis {start|stop}
|
256
|
+
|
257
|
+
3) Setup rhoconnect application directory
|
258
|
+
|
259
|
+
A) Put your application code in a directory called /var/www/rhoconnect
|
260
|
+
(make sure this is the root of your applictaion directory, i.e. /var/www/rhoconnect/config.ru should exist).
|
261
|
+
|
262
|
+
B) Make an empty public folder in the directory
|
263
|
+
$ mkdir /var/www/rhoconnect/public
|
264
|
+
|
265
|
+
_README_
|
266
|
+
|
267
|
+
readme
|
268
|
+
end #generate_common_info
|
269
|
+
|
270
|
+
def create_passenger_load
|
271
|
+
if @dist == 'debian'
|
272
|
+
passenger_load_file = '/etc/apache2/mods-available/passenger.load'
|
273
|
+
else
|
274
|
+
passenger_load_file = '/etc/httpd/conf.d/passenger.conf'
|
275
|
+
end # if
|
276
|
+
|
277
|
+
passenger_load = <<_PASSENGER_LOAD_
|
278
|
+
LoadModule passenger_module /opt/rhoconnect/lib/ruby/gems/1.8/gems/passenger-3.0.8/ext/apache2/mod_passenger.so
|
279
|
+
PassengerRoot /opt/rhoconnect/lib/ruby/gems/1.8/gems/passenger-3.0.8
|
280
|
+
PassengerRuby /opt/rhoconnect/bin/ruby
|
281
|
+
_PASSENGER_LOAD_
|
282
|
+
|
283
|
+
File.open( passenger_load_file, 'w' ) { |f| f << passenger_load }
|
284
|
+
end #create_passenger_load
|
285
|
+
|
286
|
+
def create_apache_vhost
|
287
|
+
if @dist == 'debian'
|
288
|
+
vhost_file = '/etc/apache2/sites-available/rhoconnect'
|
289
|
+
else
|
290
|
+
vhost_file = '/etc/httpd/conf.d/rhoconnect.conf'
|
291
|
+
end
|
292
|
+
vhost = <<_VHOST_
|
293
|
+
<VirtualHost *:80>
|
294
|
+
ServerName your.server.name.goes.here.com
|
295
|
+
DocumentRoot /var/www/rhoconnect/public
|
296
|
+
PassengerMaxPoolSize 20
|
297
|
+
PassengerMinInstances 6
|
298
|
+
#...
|
299
|
+
<Directory /var/www/rhoconnect/public
|
300
|
+
AllowOverride all
|
301
|
+
Options -MultiViews
|
302
|
+
</Directory>
|
303
|
+
</VirtualHost>
|
304
|
+
_VHOST_
|
305
|
+
|
306
|
+
File.open( vhost_file, 'w' ) { |f| f << vhost }
|
307
|
+
end #create_apache_vhost
|
308
|
+
|
309
|
+
# create_debian_readme
|
310
|
+
# Creates the debian specific part of the readme and places it in options[:prefix]
|
311
|
+
def create_debian_readme
|
312
|
+
readme = <<_README_
|
313
|
+
4) Configure Apache2
|
314
|
+
A) Configure virtual host for rhoconnect application:
|
315
|
+
Edit the file /etc/apache2/sites-available/rhoconnect so that it
|
316
|
+
reflects your specifications.
|
317
|
+
|
318
|
+
B) Enable the virtual host:
|
319
|
+
$ sudo a2ensite rhoconnect
|
320
|
+
|
321
|
+
C) Load the passenger.load module
|
322
|
+
$ sudo a2enmod passenger.load
|
323
|
+
|
324
|
+
D) Restart apache to pick up the changes:
|
325
|
+
$ sudo /etc/init.d/apache2 restart
|
326
|
+
_README_
|
327
|
+
|
328
|
+
readme
|
329
|
+
end #create_debian_readme
|
330
|
+
|
331
|
+
# create_yum_readme
|
332
|
+
# Creates the non-debian specific part of the readme file and places it in options[:prefix]
|
333
|
+
def create_yum_readme
|
334
|
+
readme = <<_README_
|
335
|
+
4) Configure Apache2
|
336
|
+
A) Configure virtual host for rhoconnect application:
|
337
|
+
Edit the file /etc/httpd/conf.d/rhoconnect.conf so that it
|
338
|
+
reflects your specifications.
|
339
|
+
|
340
|
+
B) Restart apache to pick up the changes:
|
341
|
+
$ sudo /sbin/service httpd restart
|
342
|
+
_README_
|
343
|
+
|
344
|
+
readme
|
345
|
+
end #create_yum_readme
|
346
|
+
|
347
|
+
def create_texts
|
348
|
+
if @redis
|
349
|
+
create_redis_init
|
350
|
+
create_redis_logrotate
|
351
|
+
end
|
352
|
+
|
353
|
+
create_passenger_load
|
354
|
+
create_apache_vhost
|
355
|
+
|
356
|
+
puts generate_common_info
|
357
|
+
distro_info = (@dist == 'debian') ? create_debian_readme : create_yum_readme
|
358
|
+
puts distro_info
|
359
|
+
|
360
|
+
File.open("#{@prefix}README", 'w') do |f|
|
361
|
+
f << generate_common_info
|
362
|
+
f << distro_info
|
363
|
+
end
|
364
|
+
end #create_texts
|
365
|
+
|
366
|
+
create_texts
|
@@ -0,0 +1,140 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'fog'
|
5
|
+
require 'readline'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
REGION = 'us-west-1'
|
9
|
+
SLEEP = 45
|
10
|
+
KEYS = '/home/mike/.ssh/alexdevkey.pem'
|
11
|
+
USER = 'ubuntu'
|
12
|
+
ACCESS_KEY_FILE = '/Users/rhomobile/.ec2'
|
13
|
+
LOCAL_REPO = '/home/mike/git/rhoconnect.tgz'
|
14
|
+
REMOTE_REPO = "/home/#{USER}/git/rhoconnect"
|
15
|
+
STACKS = [ { :image_id => 'ami-3d491a78',
|
16
|
+
:flavor_id => 'm1.small',
|
17
|
+
:key_name => 'alexdevkey',
|
18
|
+
:groups => 'load-test' },
|
19
|
+
{}
|
20
|
+
]
|
21
|
+
|
22
|
+
# cmd
|
23
|
+
# easily issue system commands in a clear way
|
24
|
+
def cmd(cmd)
|
25
|
+
puts cmd
|
26
|
+
puts `#{cmd}`
|
27
|
+
end #cmd
|
28
|
+
|
29
|
+
# create_ec2_instance
|
30
|
+
# Generates the Fog object and creates a new ec2 instance.
|
31
|
+
def create_ec2_instance
|
32
|
+
make_fog
|
33
|
+
start_new_instance
|
34
|
+
end #create_ec2_instance
|
35
|
+
|
36
|
+
# get_access_keys
|
37
|
+
# Retrieves the access key and secret access key from the above specified file.
|
38
|
+
def get_access_keys
|
39
|
+
lines = IO.readlines ACCESS_KEY_FILE
|
40
|
+
@access_key = lines.first.strip
|
41
|
+
@secret_access_key = lines.last.strip
|
42
|
+
end #get_access_keys
|
43
|
+
|
44
|
+
# make_fog
|
45
|
+
# Generates the Fog object used to create the new ec2 instance.
|
46
|
+
def make_fog
|
47
|
+
get_access_keys
|
48
|
+
@fog = Fog::Compute.new(
|
49
|
+
:provider => 'AWS',
|
50
|
+
:region => REGION,
|
51
|
+
:aws_access_key_id => @access_key,
|
52
|
+
:aws_secret_access_key => @secret_access_key
|
53
|
+
)
|
54
|
+
end #make_fog
|
55
|
+
|
56
|
+
# start_new_instance
|
57
|
+
# Creates a new ec2 instance as per the given stack.
|
58
|
+
def start_new_instance
|
59
|
+
puts "Creating new instance..."
|
60
|
+
|
61
|
+
@server = @fog.servers.create(STACKS[0])
|
62
|
+
@server.wait_for { print "."; STDOUT.flush; ready? }
|
63
|
+
puts
|
64
|
+
if @server.ready?
|
65
|
+
# wait for all services to start on remote VM
|
66
|
+
puts "Waiting #{SLEEP} seconds for services to start on remote VM..."
|
67
|
+
SLEEP.times do
|
68
|
+
sleep( 1 )
|
69
|
+
print "."
|
70
|
+
STDOUT.flush
|
71
|
+
end #do
|
72
|
+
puts
|
73
|
+
|
74
|
+
# save important instance information
|
75
|
+
@host = @server.dns_name
|
76
|
+
@server_id = @server.id
|
77
|
+
else
|
78
|
+
puts "Server timed out."
|
79
|
+
exit
|
80
|
+
end #if
|
81
|
+
end #start_new_instance
|
82
|
+
|
83
|
+
# establish_ssh_connection
|
84
|
+
# Establishes the ssh connection needed to issue commands to the remote machine.
|
85
|
+
def establish_ssh_connection
|
86
|
+
@ssh = Fog::SSH.new( @host, USER, :keys => KEYS )
|
87
|
+
end #establish_ssh_connection
|
88
|
+
|
89
|
+
# establish_scp_connection
|
90
|
+
# Establishes a gateway through which to transfer data
|
91
|
+
def establish_scp_connection
|
92
|
+
@scp = Fog::SCP.new( @host, USER, :keys => KEYS )
|
93
|
+
end #create_scp_connection
|
94
|
+
|
95
|
+
# ssh_cmd
|
96
|
+
# More easily issue commands over the ssh connection.
|
97
|
+
def ssh_cmd(cmd)
|
98
|
+
puts cmd
|
99
|
+
result = @ssh.run(cmd)
|
100
|
+
if result[0] != nil
|
101
|
+
print result[0].stdout
|
102
|
+
end #if
|
103
|
+
end #ssh_cmd
|
104
|
+
|
105
|
+
#
|
106
|
+
def transfer(local_data, remote_data)
|
107
|
+
puts "Attempting to establish SCP connection..."
|
108
|
+
puts "DATA: LOCAL - #{local_data}\t REMOTE - #{remote_data}"
|
109
|
+
@scp.upload( local_data, remote_data, :recursive => true ) do |cd, name, sent, total|
|
110
|
+
print "\r#{name}: #{(sent.to_f * 100 / total.to_f).to_i}%"
|
111
|
+
end #do
|
112
|
+
puts
|
113
|
+
|
114
|
+
end #establish_scp_connection
|
115
|
+
|
116
|
+
# transfer_rhoconnect
|
117
|
+
# Transfers over SCP the rhoconnect repo
|
118
|
+
def transfer_rhoconnect
|
119
|
+
ssh_cmd [ "sudo mkdir -p #{REMOTE_REPO}", "sudo chmod 777 #{REMOTE_REPO}" ]
|
120
|
+
transfer LOCAL_REPO, "#{REMOTE_REPO}"
|
121
|
+
ssh_cmd "sudo tar -xzf -C #{REMOTE_REPO} #{REMOTE_REPO}/rhoconnect.tgz"
|
122
|
+
ssh_cmd "ls -la #{REMOTE_REPO}"
|
123
|
+
end #transfer_rhoconnect
|
124
|
+
|
125
|
+
# destroy_ec2_instance
|
126
|
+
# Terminates the current ec2 instance
|
127
|
+
def destroy_ec2_instance
|
128
|
+
@server.destroy
|
129
|
+
puts "Instance Terminated."
|
130
|
+
end #destroy_ec2_instance
|
131
|
+
|
132
|
+
create_ec2_instance
|
133
|
+
|
134
|
+
# Establish connections
|
135
|
+
establish_ssh_connection
|
136
|
+
establish_scp_connection
|
137
|
+
|
138
|
+
transfer_rhoconnect
|
139
|
+
|
140
|
+
destroy_ec2_instance
|