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

本文介绍了将不同语言服务部署到同一个应用程序 [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)

推荐答案

appspot.com 上生成的应用程序的命名将与您提到的有点不同,因为 url 路由规则.来自 通过 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)

为每个服务创建应用程序子目录(遵循以前推荐的多服务应用程序结构图不再在文档中找到,而是在 可以在 Google 中使用默认服务/模块就文件夹结构而言,App Engine 应用是非默认应用的兄弟吗?)

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 作业需要配置目标(请参阅 <a href="https://cloud.google.com/appengine/docs/python/config/cronref#cron_job_definitions" rel=" 中的 target 行nofollow noreferrer" target="_blank">Cron 作业定义).

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 作业,来自 <a href="https://cloud.google.com/appengine/docs/python/config/cronref#cron_job_definitions" rel="nofollow noreferrer 中的 target 行" target="_blank">Cron 作业定义:

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.yamldispatch.yaml文件,作业将在 module2 中运行,即使它的目标是模块1:

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]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1171

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1071

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this-&gt;id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:808

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this-&gt;id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:900

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:930

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:877

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:865

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:834

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1733

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1308