Module: AppEngine::Tasks

Defined in:
lib/appengine/tasks.rb

Overview

App Engine Rake Tasks.

To make these tasks available, add the line require "appengine/tasks" to your Rakefile. If your app uses Ruby on Rails, then the appengine gem provides a railtie that adds its tasks automatically, so you don't have to do anything beyond adding the gem to your Gemfile.

The following tasks are defined:

Rake appengine:exec

Executes a given command in the context of an App Engine application, using App Engine remote execution. See Exec for more information on this capability.

The command to be run may either be provided as a rake argument, or as command line arguments, delimited by two dashes --. (The dashes are needed to separate your command from rake arguments and flags.) For example, to run a production database migration, you can run either of the following equivalent commands:

bundle exec rake "appengine:exec[bundle exec bin/rails db:migrate]"
bundle exec rake appengine:exec -- bundle exec bin/rails db:migrate

To display usage instructions, provide two dashes but no command:

bundle exec rake appengine:exec --

Parameters

You may customize the behavior of App Engine execution through a few enviroment variable parameters. These are set via the normal mechanism at the end of a rake command line. For example, to set GAE_CONFIG:

bundle exec rake appengine:exec GAE_CONFIG=myservice.yaml -- bundle exec bin/rails db:migrate

Be sure to set these parameters before the double dash. Any arguments following the double dash are interpreted as part of the command itself.

The following environment variable parameters are supported:

GAE_TIMEOUT

Amount of time to wait before appengine:exec terminates the command. Expressed as a string formatted like: "2h15m10s". Default is "10m".

GAE_PROJECT

The ID of your Google Cloud project. If not specified, uses the current project from gcloud.

GAE_CONFIG

Path to the App Engine config file, used when your app has multiple services, or the config file is otherwise not called ./app.yaml. The config file is used to determine the name of the App Engine service.

GAE_SERVICE

Name of the service to be used. Overrides any service name specified in your config file.

GAE_EXEC_STRATEGY

The execution strategy to use. Valid values are "deployment" (which is the default for App Engine Standard apps) and "cloud_build" (which is the default for App Engine Flexible apps).

Normally you should leave the strategy set to the default. The main reason to change it is if your app runs on the Flexible Environment and talks to a database over a VPC (using a private IP address). The "cloud_build" strategy used by default for Flexible apps cannot connect to a VPC, so you should use "deployment" in this case. (But note that, otherwise, the "deployment" strategy is significantly slower for apps on the Flexible environment.)

GAE_VERSION

The version of the service, used to identify which application image to use to run your command. If not specified, uses the most recently created version, regardless of whether that version is actually serving traffic. Applies only to the "cloud_build" strategy. (The "deployment" strategy deploys its own temporary version of your app.)

GAE_EXEC_WRAPPER_IMAGE

The fully-qualified name of the wrapper image to use. (This is a Docker image that emulates the App Engine environment in Google Cloud Build for the "cloud_build" strategy, and applies only to that strategy.) Normally, you should not override this unless you are testing a new wrapper.

CLOUD_BUILD_GCS_LOG_DIR

GCS bucket name of the cloud build log when GAE_STRATEGY is "cloud_build". (ex. "gs://BUCKET-NAME/FOLDER-NAME")