简体   繁体   English

将不同语言的服务部署到同一个应用程序[Google App Engine]

[英]Deploying different languages services to the same Application [Google App Engine]

I have two applications, one in Python and the other one in Java. 我有两个应用程序,一个在Python中,另一个在Java中。

In Python, my application is under a Service which is set in the app.yaml , also the cron.yaml calls the service. 在Python中,我的应用程序是在设置服务下app.yaml ,也cron.yaml调用服务。

In my (Maven) Java app, it is not under a Service so it is the default service (which I will change if needed). 在我的(Maven)Java应用程序中,它不在服务之下,因此它是默认服务(如果需要,我将更改)。 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 ./WEB-INF/cron.xml文件和../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

and

java-app.project.appspot.com

instead of the current 而不是当前

python-app.project1.appspot.com

and

project2.appspot.com

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. 我没有尝试使用app.yaml和appengine-web.xml文件,因为我不知道是否要修改它们。

How do I make different services (modules) with differents languages (Python and Java) 如何使用不同的语言(Python和Java)创建不同的服务(模块)

The naming of the resulting app on appspot.com will be a bit different than what you mentioned, because of the url routing rules. 由于url路由规则, appspot.com上生成的应用程序的命名与您提到的有点不同。 From Routing via URL : 路由到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 

So, assuming your services are named python and java and you app is named app then your appspot.com URLs woulds be: 因此,假设您的服务名为pythonjava并且您的app被命名为app那么您的appspot.com URL将是:

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: 至于建立这样的应用程序:

  • keep in mind that one of the services needs to me named default (or remain unnamed) 请记住,其中一项服务需要我命名为default (或保持未命名)

  • 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? ) 为每个服务创建应用程序子目录(遵循以前在文档中找不到的多服务应用程序结构图片,但在Google App Engine应用程序中的默认服务/模块中捕获的是非的兄弟在文件夹结构方面默认一个?

  • copy the entire content of each service code into the respective subdir 将每个服务代码的全部内容复制到相应的子目录中

  • 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). 识别你拥有的应用程序级配置文件( cron.yamldispatch.yamlqueue.yamlindex.yaml或它们的java等价物),并在应用程序级别目录中将它们向上移动一级(如果需要,可能需要合并它们)这样的配置文件存在于两个服务中)。 You may need to choose one language for these files, I'd choose python. 您可能需要为这些文件选择一种语言,我会选择python。 Cron jobs would need to have targets configured (see target row in Cron job definitions ). Cron作业需要配置目标(请参阅Cron作业定义中的 target行)。

    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. 在部署服务时,您应该留意可能覆盖这些配置,您可能需要提出一定的部署顺序。

  • 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. 添加dispatch.yaml文件并重新访问/调整服务的请求路径名称空间可能是一个好主意(可能是强制性的),以确保每个请求都正确定向到相应的服务。 Special attention for cron jobs, from the target row in Cron job definitions : cron作业定义中 target行的cron作业特别注意:

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.yamldispatch.yaml文件,作业将在module2中运行,即使其目标是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 https://cloud.google.com/appengine/docs/python/config/cronref#cron_job_definitions

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM