Class: Google::Cloud::Gemserver::CLI::Server
- Inherits:
-
Object
- Object
- Google::Cloud::Gemserver::CLI::Server
- Defined in:
- lib/google/cloud/gemserver/cli/server.rb
Overview
Server
Object responsible for deploying the gemserver to Google Cloud Platform and starting it.
Instance Attribute Summary collapse
-
#config ⇒ Configuration
readonly
The Configuration object used to deploy the gemserver.
Instance Method Summary collapse
-
#delete(proj_id) ⇒ Object
Deletes a given gemserver by its parent project’s ID.
-
#deploy ⇒ Object
Deploys the gemserver to Google Cloud Platform if the app environment variable is set to “production.” Otherwise, the gemserver is started locally.
-
#initialize ⇒ Server
constructor
Creates a Server instance by initializing a Configuration object that will be used to access paths to necessary configuration files.
-
#start ⇒ Object
Starts the gemserver by starting up the gemstash server with predefined options.
-
#update ⇒ Object
Updates the gemserver on a Google Cloud Platform project by redeploying it.
Constructor Details
#initialize ⇒ Server
Creates a Server instance by initializing a Configuration object that will be used to access paths to necessary configuration files.
40 41 42 |
# File 'lib/google/cloud/gemserver/cli/server.rb', line 40 def initialize @config = Configuration.new end |
Instance Attribute Details
#config ⇒ Configuration (readonly)
The Configuration object used to deploy the gemserver
35 36 37 |
# File 'lib/google/cloud/gemserver/cli/server.rb', line 35 def config @config end |
Instance Method Details
#delete(proj_id) ⇒ Object
Deletes a given gemserver by its parent project’s ID.
was deployed to.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/google/cloud/gemserver/cli/server.rb', line 90 def delete proj_id return unless Configuration.deployed? full_delete = user_input("This will delete the entire Google Cloud"\ " Platform project #{proj_id}. Continue"\ " deletion? (Y|n, default n) If no, all relevant resources will"\ " be deleted besides the parent GCP project.").downcase if full_delete == "y" puts "Deleting gemserver with parent project" system "gcloud projects delete #{proj_id}" else @config.delete_from_cloud del_gcs_files inst = @config.app["beta_settings"]["cloud_sql_instances"] .split(":").pop puts "Deleting child Cloud SQL instance #{inst}..." params = "delete #{inst} --project #{proj_id}" status = system "gcloud beta sql instances #{params}" fail "Unable to delete instance" unless status puts "The Cloud SQL instance has been deleted. Visit:\n "\ "https://console.cloud.google.com/appengine/settings?project="\ "#{proj_id} and click \"Disable Application\" to delete the "\ "Google App Engine application the gemserver was deployed to." end end |
#deploy ⇒ Object
Deploys the gemserver to Google Cloud Platform if the app environment variable is set to “production.” Otherwise, the gemserver is started locally.
66 67 68 69 70 71 72 73 74 |
# File 'lib/google/cloud/gemserver/cli/server.rb', line 66 def deploy begin return start if ["test", "dev"].include? ENV["APP_ENV"] deploy_to_gae setup_default_keys ensure cleanup end end |
#start ⇒ Object
Starts the gemserver by starting up the gemstash server with predefined options.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/google/cloud/gemserver/cli/server.rb', line 47 def start path = if ENV["APP_ENV"] == "production" Configuration::GAE_PATH else @config.config_path end args = [ "start", "--no-daemonize", "--config-file=#{path}" ].freeze Google::Cloud::Gemserver::Backend::StorageSync.download_service Google::Cloud::Gemserver::Backend::GemstashServer.start args end |
#update ⇒ Object
Updates the gemserver on a Google Cloud Platform project by redeploying it.
79 80 81 82 83 |
# File 'lib/google/cloud/gemserver/cli/server.rb', line 79 def update return unless Configuration.deployed? puts "Updating gemserver..." deploy_to_gae end |