You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Google Cloud SDK Shell实现Google App Engine项目本地运行与部署

本地运行与部署Google App Engine项目(替代已弃用的App Engine Launcher)

Got it, let's walk through this clearly—since Google retired the App Engine Launcher, we'll use the Cloud SDK Shell commands to handle both local testing and cloud deployment. It's straightforward once you follow these steps:

一、本地运行项目(Local Development Server)

First, make sure you have your App Engine project ready (with all your code files) and the Google Cloud SDK installed (which you already do, since you have the Cloud SDK Shell).

  • Step 1: Navigate to your project folder
    Open the Cloud SDK Shell, then use the cd command to move to your project's root directory. For example:

    # Windows
    cd C:\Users\YourName\Projects\MyAppEngineProject
    
    # Mac/Linux
    cd ~/Projects/MyAppEngineProject
    

    Your project root needs to have an app.yaml file—this is the core configuration file for App Engine. If you don't have one, create it based on your runtime (here's a Python 3 example):

    runtime: python39
    service: default
    handlers:
    - url: /.*
      script: auto
    
  • Step 2: Start the local development server
    Run this command to launch the local server:

    dev_appserver.py app.yaml
    

    By default, the server runs on http://localhost:8080—open that in your browser to see your app live locally. If you need a different port, add the --port flag:

    dev_appserver.py app.yaml --port=8081
    
  • Step 3: Test and iterate
    The local server auto-reloads when you modify your code, so you can make changes, save, and refresh the browser to see updates immediately. Check the Cloud SDK Shell output for logs and error messages if something isn't working.

二、线上部署到Google App Engine

Once you're happy with your local testing, deploy it to the cloud with these steps:

  • Step 1: Authenticate your Google account
    Make sure you're logged into the Google account linked to your Cloud Platform project:

    gcloud auth login
    

    A browser window will pop up—select your account and grant the necessary permissions.

  • Step 2: Set your target project
    Tell the SDK which Cloud Platform project you want to deploy to (replace YOUR_PROJECT_ID with your actual project ID from the Cloud Console):

    gcloud config set project YOUR_PROJECT_ID
    
  • Step 3: Deploy your app
    Run this command to start the deployment process:

    gcloud app deploy
    

    You'll be prompted to select a region (pick one close to your users, e.g., us-central1). Confirm the deployment, and wait for the process to finish—it may take a minute or two depending on your app's size.

  • Step 4: Access your live app
    Once deployment succeeds, you can open your app directly with:

    gcloud app browse
    

    This will launch your browser to the live URL (usually https://YOUR_PROJECT_ID.uc.r.appspot.com).

Quick Troubleshooting Tips

  • If deployment fails, check the Shell output for specific errors—common issues include missing dependencies (e.g., a requirements.txt for Python projects) or invalid app.yaml syntax.
  • To deploy a specific version of your app, add the --version flag: gcloud app deploy --version=v2
  • If you need to deploy a non-default service, update the service field in your app.yaml and deploy as usual.

内容的提问来源于stack exchange,提问作者Vignesh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:50:14