Google Cloud Platform

Uploading, Downloading, and Managing a Go App

The App Engine Go SDK includes the goapp deploy command for uploading your app to App Engine.

The App Engine Go SDK includes a second command for interacting with App Engine named You can use this command to upload new versions of the code, configuration and static files for your app to App Engine. You can also use the command to manage datastore indexes and download log data. uses your Google account to authenticate. The default authentication scheme is OAuth 2.0, which asks the user to login and authorize appcfg through a browser. After a successful authorization, stores the access token so that the user is not prompted again for subsequent attempts. The token can be deleted by manually removing .appcfg_oauth2_tokens found in the user's home directory. You can also specify the --no_cookies option to prevent the token from being stored at all. In the case where you do not have access to the browser on the machine that runs, specify the --noauth2_local_webserver option and follow the instructions to authenticate.

Note: If you created your project using the Google Cloud Platform Console, your project has a title and an ID. In the instructions that follow, the project title and ID can be used wherever an application title and ID are mentioned. They are the same thing.

  1. Uploading the app
  2. Updating indexes
  3. Deleting unused indexes
  4. Updating Task Queue configuration
  5. Updating the dispatch file
  6. Updating the DoS protection configuration
  7. Managing scheduled tasks
  8. Downloading source code
  9. Downloading logs
  10. Using an HTTP proxy
  11. Command line arguments

Uploading the app

The simplest way to upload application files is to run goapp deploy from within the root directory of your application. The root directory should contain the app.yaml file for the application.

goapp deploy

Alternatively, you can provide the location of your application's root directory as an additional argument. For help using the tool, run goapp help deploy for a full description of its options.

goapp deploy wraps the python tool provided in the SDK. You can also invoke this tool directly if you need greater control over the deployment: update myapp/ and goapp deploy get the application ID from the app.yaml automatically.

You can also override the ID by using the -A option when calling -A <YOUR_PROJECT_ID> update myapp/
Or by using -application when calling goapp.

goapp deploy -application <YOUR_PROJECT_ID> myapp/

Note that many of our sample applications in this documentation omit application: from the app.yaml file. In such cases, use the -A or -application options when deploying.

If you factor your application into Modules you can specify one or more yaml files for your modules in the update command.

cd myapp update main/app.yaml mod1/mod1.yaml mod2/mod2.yaml

Updating indexes

When you upload an application using update, the update includes the app's index.yaml file. If the index.yaml file defines an index that doesn't exist yet on App Engine, App Engine creates the new index. Depending on how much data is already in the datastore that needs to be mentioned in the new index, the process of creating the index may take a while. If the app performs a query that requires an index that hasn't finished building yet, the query will raise an exception.

To prevent this, you must ensure that the new version of the app that requires a new index is not the live version of the application until the indexes finish building. One way to do this is to give the app a new version number in app.yaml whenever you add or change an index in index.yaml. The app is uploaded as a new version, and does not become the default version automatically. When your indexes have finished building, you can change the default version in the Cloud Platform Console.

Another way to ensure that new indexes are built before the new app goes live is to upload the index.yaml configuration separately before uploading the app. To upload only the index configuration for an app, use the following command: update_indexes myapp/

In the Cloud Platform Console, you can check the status of the app's indexes.

Deleting unused indexes

When you change or remove an index from index.yaml, the original index is not deleted from App Engine automatically. This gives you the opportunity to leave an older version of the app running while new indexes are being built, or to revert to the older version immediately if a problem is discovered with a newer version.

When you are sure that old indexes are no longer needed, you can delete them from App Engine using the following command: vacuum_indexes myapp/

This command deletes all indexes for the app that are not mentioned in the local version of index.yaml.

Updating Task Queue configuration

To update the task queue configuration, use the update_queues command. Note that you specify the directory that contains queue.yaml, not the file: update_queues myapp/

If you update a module by performing the update command on a directory that contains an app.yaml file and a queue.yaml file, the task queue configuration will be uploaded as well.

Updating the dispatch file

To update the dispatch file, use the update_dispatch command. Note that you specify the directory that contains dispatch.yaml, not the file: -A <PROJECT_ID> update_dispatch myapp/

Be sure that all the modules mentioned in the file have been uploaded before using this command.

If you update a module by performing the update command on a directory that contains an app.yaml file and a dispatch.yaml file, the dispatch file will be uploaded as well.

Updating the DoS protection configuration

To update the DoS protection, use the update_dos command. Note that you specify the directory that contains dos.yaml, not the file: update_dos myapp/

If you update a module by performing the update command on a directory that contains an app.yaml file and a dos.yaml file, the DoS protection configuration will be uploaded as well.

Managing scheduled tasks

App Engine supports scheduled tasks (known as cron jobs). You specify these in a file called cron.yaml.

To update the cron job configuration, use the update_cron command. Note that you specify the directory that contains cron.yaml, not the file: update_cron myapp/

The command displays a summary of the scheduled task configuration, and the expected times of the next few runs. For more on cron jobs, see the Cron Jobs documentation.

If you run the update specifying a directory that contains an app.yaml file and a cron.yaml file, the cron job configuration will be updated as well.

Downloading source code

You can download an application's source code by running with the download_app action in the Go SDK command-line tool: download_app -A <your_app_id> -V <your_app_version> <output-dir>

Output like the following results if the command is successful:

Getting file list...
Email: <admin-id>
Password for <admin-id>
Fetching files...
Getting files...

[3/5] static/screen.css
[4/5] static/print.css
[5/5] images/bird.png

Only the developer who uploaded the code and the application owner(s) can download it. If anyone other than these parties attempts to download the app, they'll see an error message like the following:

Fetching file list...
Password for
Error 403: --- begin server output ---
You do not have permission to download this app version.
--- end server output ---

Downloading logs

App Engine maintains a log of messages that your application emits through methods on appengine.Context. App Engine also records each request in the log. Each log level has a fixed buffer size that controls the amount of log information you can access. Normally, you use logging features more at lower log levels; thus, the time window is smaller for log events at these levels. In the Cloud Platform Console, you can browse your app's logs of the last 90 days.

If you wish to perform more detailed analysis of your application's logs, you can download the log data to a file on your computer. To download logs to a file named mylogs.txt, use the following command: request_logs myapp/ mylogs.txt

By default, the command downloads log messages from the current calendar day (since midnight Pacific Time) with a log level of INFO or higher (omitting DEBUG level messages). The command overwrites the local log file. You can adjust the number of days, the minimum log level, and whether to overwrite or append to the local log file using command-line options. See below for more information on these options.

You can limit the log messages that are downloaded to just those emitted during request on a given domain name using the --vhost=... option. You can use this to download the logs for your live app using a Google Apps domain or, excluding log messages emitted by versions you are testing on URLs such as Or you can use it to download just the log messages for a given test domain.

There are many options for the request_logs command. You can view them all by typing: help request_logs

Using an HTTP proxy

If you are running behind an HTTP proxy, you must tell the name of the proxy. To set an HTTP proxy for, set the http_proxy and https_proxy environment variables.

Using Windows (in Command Prompt):

set HTTPS_PROXY= update myapp

Using the command line in Mac OS X (in Terminal) or Linux:

export http_proxy="" update myapp

Command line arguments

The command takes a set of options, an action, and arguments for the action.

The App Engine SDK is updated frequently, and this list of arguments may not be current. Type help to see the list of all available actions, and help <action> for details on a particular action. [options] update <app-directory>|<files...>

If you specify a directory, it must contain an app.yaml file and all of the other files required by the app (or module that the app.yaml file defines). If the directory contains any global application settings files (index.yaml, queues.yaml, dispatch.yaml, dos.yaml, cron.yaml) they will also be uploaded. Note that if there are other module configuration files in the directory they will not be uploaded. You'll need to specify them using update with a file list.

The update action creates or updates the app version named in the app.yaml file at the top level of the directory. It follows symlinks and recursively uploads all files to the server. Temporary or source control files (e.g. foo~, .svn/*) are skipped.

Use the files argument to upload one or more yaml files that define modules. No other types of yaml files can appear in the command line. Only the specified modules will be updated.

The following option applies to update:

Maximum size of a file to upload (in bytes). help <action>
Prints a help message about the given action, then quits. [options] cron_info <app-directory>
Displays information about the scheduled task (cron) configuration, including the expected times of the next few executions. By default, displays the times of the next 5 runs. You can modify the number of future run times displayed with the --num_runs=... option. download_app -A <app_id> -V <version> <output-dir>

Retrieves the most current version of your application's code using the following options:

The application ID (required).
Optional; specifies the version of the code to download. If omitted, the default version will be downloaded.
The directory where you wish to save the files (required). [options] request_logs <app-directory> <output-file>

Retrieves log data for the application running on App Engine. output-file is the name of the file to create, replace or append (if the --append flag is set). If output-file is a hyphen (-), the log data is printed to the console. The following options apply to request_logs:

The number of days of log data to retrieve, ending on the current date at midnight UTC. A value of 0 retrieves all available logs. If --append is given, then the default is 0, otherwise the default is 1.
The latest date of log data to return, in the form YYYY-MM-DD. The default is today. The --num_days option counts backwards from the end date.
The minimum log level for the log messages to retrieve. The value is a number corresponding to the log level: 4 for CRITICAL, 3 for ERROR, 2 for WARNING, 1 for INFO, 0 for DEBUG. All messages at the given log level and above will be retrieved. Default is 1 (INFO).

Append the fetched data to the output file, starting with the first log line not already present in the file. Running this action once a day with --append results in a file containing all log data.

The default is to overwrite the output file. Does not apply if output-file is - (printing to the console).


If present, limits the log messages downloaded to just those emitted by requests for a given domain name. For instance, will download just the log messages for the live app at the Google Apps domain, excluding any log messages emitted by a new version being tested at Similarly, downloads just the logs for the test version, excluding the live version.

The value is a regular expression that matches the Host header of the incoming requests. Note that the pattern is case sensitive, even though domain names usually are not.


Include the domain name for each request (the Host request header) in the request log data, as an additional field. [options] rollback <app-directory>
Undoes a partially completed update for the given application. You can use this if an update was interrupted, and the command is reporting that the application cannot be updated due to a lock. [options] set_default_version <app-directory>
Specifies the default version of the given module. [options] migrate_traffic <app-directory>
Implements traffic migration. Dynamically re-routes traffic from the current default (serving) version of the app to the the version specified in the app.yaml. Traffic is gradually moved from the old to the new version. Once all traffic is being sent to the new version, sets the default (serving) version of the app to the version specified in the app.yaml. [options] list_versions <app-directory>
Outputs the uploaded versions for each module of an application in YAML. The YAML is in formatted as an associative array, mapping module_ids to the list of versions uploaded for that module. The default version will be first in the list. [options] delete_version -A app_id -V version
Deletes the specified version for the specified application. [options] update_cron <app-directory>
Updates the schedule task (cron) configuration for the app, based on the cron.yaml file. [options] update_dos <app-directory>
Updates the DoS Protection configuration for the app, based on the dos.yaml file. [options] update_indexes <app-directory>
Updates datastore indexes in App Engine to include newly added indexes. If a new version of your application requires an additional index definition that was added to index.yaml, you can update your index definitions in App Engine prior to uploading the new version of your application. Running this action a few hours prior to uploading your new application version will give the indexes time to build and be serving when the application is deployed. [options] update_queues <app-directory>
Updates the task queue configuration for the app, based on the queue.yaml file. [options] update_dispatch <app-directory>
Updates the dispatch for the app, based on the dispatch.yaml file. [options] start_module_version <app-directory>

Start the specified module version.

Use the --module and --version options to override the settings in the app.yaml file. [options] stop_module_version <app-directory>

Stop the specified module version.

Use the --module and --version options to override the settings in the app.yaml file. [options] vacuum_indexes <app-directory>
Deletes unused datastore indexes in App Engine. If an index definition is removed from index.yaml, the index is not deleted automatically when the application is uploaded because it may be in use by another version of the application. Run this action when all old indexes are no longer needed.

The command accepts the following options for all actions:

The application ID to use. By default, this is derived from the application: line in the app.yaml file in the application directory. If --application is specified, it overrides the ID in app.yaml for this action.
Force deletion of unused indexes. By default, uploading an app does not delete unused indexes from the server, even if they do not appear in the index.yaml file.
The hostname of the local machine for use with remote procedure calls.
A maximum size of files to upload, as a number of bytes. Files larger than this size will not be uploaded. The default is 10485760. The server currently enforces a maximum file size of 10,485,760 bytes, so increasing this value will not have any effect.
The name of the module to use. By default, this is derived from the module: line in the app.yaml file in the application directory. If --module is specified, it overrides the value in app.yaml for this action.
Do not store the user's access token. Go through the OAuth2 flow every time.
Print many messages about what the command is doing. This is mostly useful when working with the App Engine team to troubleshoot an upload issue.
Don't use the web browser to display web pages for authentication. This is useful for OAuth2 authentication if you're remotely logged on to a machine. This flag only applies for OAuth2.
Use an OAuth2 refresh token to authenticate instead of the default one stored in the user's home directory.
Do not print messages when successful.
The App Engine server hostname. The default is
Print messages about what the command is doing.
The version ID to use. By default, this is derived from the version: line in the app.yaml file in the application directory. If --version is specified, it overrides the version ID in app.yaml for this action.