简体   繁体   English

Google云端平台:如何使用GCP资源在本地环境中进行开发

[英]Google Cloud Platform : How to develop on my local environment with GCP resources

I'm using Google App Engine Flex to develop an angularjs/php-rest backend application. 我正在使用Google App Engine Flex开发angularjs / php-rest后端应用程序。 I've a successful port from regular servers to AppEngine, and I now want to integrate more with GCP services like : StackDriver, Cloud Storage and so on. 我已经成功地从常规服务器移植到AppEngine,现在我想与GCP服务(如StackDriver,Cloud Storage等)进行更多集成。

StackDriver to have logging & monitoring. StackDriver具有日志记录和监视功能。 Cloud Storage: to store export data files and zip them before sending it to browser. 云存储:用于存储导出数据文件并压缩它们,然后再将其发送到浏览器。

My question is how do I develop locally on my laptop (which can be online & offline) ? 我的问题是如何在笔记本电脑(可以在线和离线)上进行本地开发?

I didn't find in the documentation "the way" of local development : 我没有在本地开发的“方式”文档中找到:

  • Should stackDriver or Cloud Storage client be configured to write on disk instead of reaching GCP ? 是否应该将stackDriver或Cloud Storage客户端配置为在磁盘上写入而不是到达GCP?
  • Should I configure some proxy (like the cloud_sql_proxy) to be able to reach GCP ? 我应该配置一些代理(例如cloud_sql_proxy)以使其能够到达GCP吗? Should I create a project for my local dev ? 我应该为我的本地开发人员创建一个项目吗? How does it work if I'm offline ? 如果我离线,该如何运作?

Any hint appreciated :) 任何提示表示赞赏:)

App Engine Flexible doesn't come with a development server or service emulators for use during development so you may use the services directly. App Engine Flexible不附带开发服务器或服务仿真器,以供在开发期间使用,因此您可以直接使用服务。

  • Stackdriver Logging : logs written to stdout and stderr are automatically sent to Stackdriver Logging for you, without needing to use Stackdriver Logging library for PHP. Stackdriver Logging :写入stdoutstderr的日志会自动为您发送到Stackdriver Logging,而无需使用PHP的Stackdriver Logging库。 This may be enough for you to get logs locally but we recommend that you use the PSR-3 logger which automatically adds metadata to your logs so that your application logs are correlated to the request logs. 这可能足以使您在本地获取日志,但是我们建议您使用PSR-3记录器,该记录器会自动将元数据添加到日志中,以便将应用程序日志与请求日志相关联。 You can set it up to run locally and log to your project by following the doc here . 您可以按照此处的文档将其设置为在本地运行并登录到您的项目。
  • Stackdriver Monitoring : Google App Engine includes built-in support for Monitoring in the flexible environment (when deployed) and doesn't require configuration. Stackdriver Monitoring :Google App Engine内置了对在灵活环境(部署时)中进行Monitor的支持,并且不需要进行配置。 The monitoring agent cannot be installed on your local machine though, but it would be pointless to monitor it anyway. 虽然不能将监视代理程序安装在本地计算机上,但是无论如何监视它都是没有意义的。
  • Cloud Storage : an easy option is to create a dev bucket that you can use during development. 云存储 :一个简单的选择是创建一个开发桶,您可以在开发期间使用它。 You can create it in whichever project you wish and grant permissions to your development service account. 您可以在任何项目中创建它,并向您的开发服务帐户授予权限。

One common practice is to create different GCP projects for prod, staging and dev purposes. 一种常见的做法是为生产,暂存和开发目的创建不同的GCP项目。 This allows you to create specific resources for a given environment. 这使您可以为给定环境创建特定资源。 Taking logging as example, you'll be able to see logs and troubleshoot any issue with it within the dev project, without polluting your prod project's logs. 以日志记录为例,您将能够在开发项目中查看日志并对其进行任何故障排除,而不会污染生产项目的日志。 That'd be true with CloudSQL, Datastore, etc... CloudSQL,数据存储区等都是如此。

You don't need to configure any proxy for those services. 您无需为这些服务配置任何代理。 The cloud_sql_proxy is a convenient method to enforce secure connections and ease authentication with CloudSQL instances without the need to whitelist IP addresses. cloud_sql_proxy是一种方便的方法,用于强制进行安全连接并简化与CloudSQL实例的身份验证,而无需将IP地址列入白名单。

Regarding the offline situation now, of course those calls from your local app to those services will fail if you don't have internet connection at that time (intermittent disconnections may actually help you to test your retries and error handling mechanisms). 对于当前的离线情况,如果您当时没有Internet连接,那么从本地应用程序到这些服务的调用当然会失败(间歇性断开实际上可以帮助您测试重试和错误处理机制)。 If you expect to develop with no internet connection at all though, you'll need to write stub services to mimic the expected behavior locally. 如果您希望在没有互联网连接的情况下进行开发,则需要编写存根服务以在本地模拟预期的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在PHP和Google Cloud Platform上部署PHP应用程序? - How can I deploy my PHP application on Google cloud Platform? 如何在谷歌云平台上搭建论坛网站? - How to setup a forum website on Google Cloud Platform? Google Cloud Platform文件位置 - Google Cloud Platform files location 如何在Windows上为Cloud SQL(GAE)设置本地环境变量 - How to setup local environment variables for Cloud SQL (GAE) on Windows 如何在Google Cloud Platform上将用户添加到MySQL实例 - How to add a user to a MySQL instance on the Google Cloud Platform 如何在Google Cloud Platform上使用Firestore正确部署PHP应用程序? - How to properly deploy PHP app with Firestore on Google Cloud Platform? 如何在Google Cloud Platform上的App Engine中更改php版本(运行时)? - How to change php version (runtime) in App Engine on Google Cloud Platform? Google Cloud Platform-如何将图像文件上传到Google Cloud Storage Bucket? - Google Cloud Platform - How to upload image file into google cloud storage bucket? 如何在php中为谷歌云语音API设置环境变量 - How to set environment variable for google cloud speech API in php 谷歌云 PHP 开发环境 - Google Cloud PHP development environment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM