【发布时间】:2018-01-22 01:00:46
【问题描述】:
我创建了一个我试图在 appengine 上托管的不和谐机器人,它运行良好,但是当闲置超过 30 分钟时,appengine 会关闭实例,原因是 - 我认为问题是 - 在哪个应用程序中自动缩放引擎关闭流量中不活动的实例以降低成本。根据 java 文档,您需要将应用程序的 appengine-web.xml 文件在 target/project-1.0/WEB-INF/appengine-web.xml 中设置为手动缩放,这也控制实例化的实例数量。但这似乎并没有解决问题。我几乎没有使用任何流量,我检查了我的实例的统计信息,它只是由于不活动而关闭。
我从控制台分离的方式是通过 java -jar project-1.0.jar & 运行我的 java 应用程序。 & 分离并使其自行运行(就是这种情况)。
激活应用并关闭控制台后 30 分钟,应用会因自动缩放而关闭。
这是我的 appengine-web.xml:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>wizardry-discord-bot</application><!-- unused for Cloud SDK based tooling -->
<version>1</version><!-- unused for Cloud SDK based tooling -->
<threadsafe>true</threadsafe>
<runtime>java8</runtime>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
</appengine-web-app>
由于这不起作用,文档不清楚,所以我也将它添加到我的 app.yaml 中的 src/main/appengine/app.yaml 中,就像我读过的许多示例一样。 同样,文档不清楚,但他们说我也可以在这里指定手动缩放。在这一点上,我不知道什么是什么,什么是哪里。
# [START_EXCLUDE]
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [END_EXCLUDE]
# [START runtime]
runtime: custom
env: flex
handlers:
- url: /.*
script: this field is required, but ignored
runtime_config: # Optional
jdk: openjdk8
server: jetty9
manual_scaling:
instances: 1
# [END runtime]
那么我在这里做错了吗?一般来说,我是谷歌云的新手。有点迷路了。
编辑:进一步: 文档说运行 mvn appengine:deploy 以实际运行您的代码,而不是编译和 java -jar'ing 它。 https://cloud.google.com/java/getting-started/hello-world 但是,当我运行命令时:https://hastebin.com/magizutuho.sql
【问题讨论】:
-
您似乎混淆了标准和弹性环境配置。该错误表明您的弹性部署可能不起作用。因此,请在开发者控制台中查看您的应用运行的具体内容以及
App Engine->Versions页面上的实际缩放参数。 -
@DanCornilescu 版本页面显示我使用的是标准版。编辑:想补充一下我想要标准。
-
缩放参数如何? (可能需要调整列的可见性)。您还可以看到当前正在部署的 实际 配置。
-
由于您想要标准环境,您可以忽略第二个配置以及 hello world 指南和部署错误 - 它们不适用。请注意,大多数(但不是全部)文档都是围绕其适用的环境构建的。
-
@DanCornilescu 缩放参数已在 appengine-web.xml 中定义。 。我正在关注文档,但遇到了问题。例如,医生说:hastebin.com/wekedesuci.pas 但我认为我应该在 target/... m 手动 git 拉上 appengine,在那里打包,然后在那里 java -jaring。不知道此时该做什么......