将不同的语言服务部署到同一应用程序[Google App Engine] [英] Deploying different languages services to the same Application [Google App Engine]

查看:82
本文介绍了将不同的语言服务部署到同一应用程序[Google App Engine]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个应用程序,一个在Python中,另一个在Java中.

I have two applications, one in Python and the other one in Java.

在Python中,我的应用程序位于app.yaml中设置的服务下,cron.yaml也会调用该服务.

In Python, my application is under a Service which is set in the app.yaml, also the cron.yaml calls the service.

在我的(Maven)Java应用程序中,它不在服务下,因此它是默认服务(如果需要,我将对其进行更改).还使用../WEB-INF/cron.xml文件以及../WEB-INF/appengine-web.xml

In my (Maven) Java app, it is not under a Service so it is the default service (which I will change if needed). The app is also called with the ../WEB-INF/cron.xml file and the informations about the app in the ../WEB-INF/appengine-web.xml

目前它们之间没有任何联系,我将两个应用程序都部署到了不同的项目中.

For now they have no connection with each other, I deployed both apps to different projects.

我想将它们融合在一起,并将它们放在与以下项目相同的项目中:

I would like to fuse them and put them in the same project as:

python-app.project.appspot.com

java-app.project.appspot.com

代替当前

python-app.project1.appspot.com

project2.appspot.com

我没有尝试使用app.yaml和appengine-web.xml文件,因为我不知道是否要修改它们.

I didn't try to play around with the app.yaml and appengine-web.xml files because I do not know if those are to be modified or not.

如何使用不同的语言(Python和Java)制作不同的服务(模块)

How do I make different services (modules) with differents languages (Python and Java)

推荐答案

由于url路由规则,在appspot.com上生成的应用程序的命名将与您提到的命名稍有不同.来自通过URL路由:

The naming of the resulting app on appspot.com will be a bit different than what you mentioned, because of the url routing rules. From Routing via URL:

将请求发送到默认版本的可用实例 命名服务:

Sends a request to an available instance of the default version of the named service:

https://service-dot-app-id.appspot.com
http://service.my-custom-domain.com

因此,假设您的服务分别命名为pythonjava,而您的应用程序被命名为app,则您的appspot.com URL将为:

So, assuming your services are named python and java and you app is named app then your appspot.com URLs woulds be:

python-dot-app.appspot.com
java-dot-app.appspot.com

但是您可以根据需要使用自定义域将它们映射.

But you can map them them however you want with custom domains.

关于构建这样的应用程序:

As for building such app:

  • 请记住,其中一项服务需要对我来说名为default(或保持未命名)

  • keep in mind that one of the services needs to me named default (or remain unnamed)

为每个服务创建应用子目录(遵循以前在文档中找不到但在

create app sub-directories for each service (following what used to be recommended multi-service app structure picture no longer found in the docs, but captured in Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?)

将每个服务代码的全部内容复制到各自的子目录中

copy the entire content of each service code into the respective subdir

标识您拥有的应用程序级别配置文件(cron.yamldispatch.yamlqueue.yamlindex.yaml或它们的Java等效文件),并将它们上移到应用程序级别目录(您可以如果两种服务中都存在此类配置文件,则可能需要合并它们.您可能需要为这些文件选择一种语言,我会选择python. Cron作业需要配置目标(请参见 Cron中的target行)职位定义).

identify the app-level configuration files (cron.yaml, dispatch.yaml, queue.yaml and index.yaml or their java equivalents) you have and move them one level up, at the app level directory (you may need to merge them if such config files are present in both services). You may need to choose one language for these files, I'd choose python. Cron jobs would need to have targets configured (see target row in Cron job definitions).

请记住,部署一个/所有模块可能并不一定像您习惯的那样更新这些文件,相反,可能需要显式地部署它们-检查相应的服务配置文档.部署服务时,您应格外注意可能会覆盖这些配置,您可能需要提出特定的部署顺序.

Remember that deploying one/all modules might not necessarily update these files as you may be used to, instead they might need to be explicitly deployed - check the respective service configuration docs. You should keep an eye out for potentially overwriting these configs when deploying the services, you may need to come up with a certain deployment sequence.

添加一个dispatch.yaml文件并重新访问/调整服务的请求路径名称空间可能是一个好主意(可能是强制性的),以确保将每个请求正确地定向到各自的服务.对cron作业的特别注意,来自 Cron作业定义中的target:

it's probably a good idea (potentially mandatory) to add a dispatch.yaml file and re-visit/adjust the request path namespaces of the services, to ensure that each request is properly directed to the respective service. Special attention for cron jobs, from the target row in Cron job definitions:

如果您使用分发文件,则您的工作可能会重新路由.为了 例如,给出以下 cron.yaml dispatch.yaml 文件,则该作业将在 module2 中运行,即使其目标是 module1 :

If you use a dispatch file, your job might be re-routed. For example, given the following cron.yaml and dispatch.yaml files, the job will run in module2, even though its target is module1:

# cron.yaml
cron:
- description: "test dispatch vs target"
  url: /tasks/hello_module2
  schedule: every 1 mins
  target: module1

# dispatch.yaml:
dispatch:
- url: '*/tasks/hello_module2'
  module: module2

https://cloud.google.com/appengine/docs /python/config/cronref#cron_job_definitions

这篇关于将不同的语言服务部署到同一应用程序[Google App Engine]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆