![](/img/trans.png)
[英]“error”: { “code”: 400, “message”: “RecognitionAudio not set.”, “status”: “INVALID_ARGUMENT” } }
[英]Server error, status code: 400, error code: 100005, message: You have exceeded your organization's memory limit
我正在嘗試使用 Cloud Foundry 將一個簡單的 Spring + Spring 引導應用程序部署到 IBM Cloud。 我的 Docker 文件如下所示:
# IBM Java SDK UBI is not available on public docker yet. Use regular
# base as builder until this is ready. For reference:
# https://github.com/ibmruntimes/ci.docker/tree/master/ibmjava/8/sdk/ubi-min
FROM ibmjava:8-sdk AS builder
LABEL maintainer="IBM Java Engineering at IBM Cloud"
WORKDIR /app
RUN apt-get update && apt-get install -y maven
COPY pom.xml .
RUN mvn -N io.takari:maven:wrapper -Dmaven=3.5.0
COPY . /app
RUN ./mvnw install
ARG bx_dev_user=root
ARG bx_dev_userid=1000
RUN BX_DEV_USER=$bx_dev_user
RUN BX_DEV_USERID=$bx_dev_userid
RUN if [ $bx_dev_user != "root" ]; then useradd -ms /bin/bash -u $bx_dev_userid $bx_dev_user; fi
# Multi-stage build. New build stage that uses the UBI as the base image.
# In the short term, we are using the OpenJDK for UBI. Long term, we will use
# the IBM Java Small Footprint JVM (SFJ) for UBI, but that is not in public
# Docker at the moment.
# (https://github.com/ibmruntimes/ci.docker/tree/master/ibmjava/8/sfj/ubi-min)
FROM adoptopenjdk/openjdk8:ubi-jre
# Copy over app from builder image into the runtime image.
RUN mkdir /opt/app
COPY --from=builder /app/target/javaspringapp-1.0-SNAPSHOT.jar /opt/app/app.jar
ENTRYPOINT [ "sh", "-c", "java -jar -XX:MaxRAM=10m /opt/app/app.jar" ]
如您所見,我將我的應用程序限制為最多使用 10MB,而我的實例有 256MB 可用。 但是,每次我部署應用程序時,都會收到以下錯誤:
此外,當我運行 ps 命令檢查正在運行的進程時,沒有任何東西會消耗我所有的 memory。
我在本地運行了相同的應用程序,它最多只需要 25MB,所以我的實例的 256MB 應該足夠了。 關於如何解決這個問題的任何想法?
注意:不幸的是,此時我不允許增加實例的容量。
[更新] 所以我決定從頭開始,在 IBM Cloud 中創建一個新的 Java Spring 應用程序。 IBM 自動將其設置為從此模板開始,該模板被克隆到您的存儲庫中。 該應用程序已正常部署,我可以訪問它。
現在,我刪除了 HTML 中的一行代碼並嘗試再次部署。 令我驚訝的是,我得到了:
FAILED
Error restarting application: Server error, status code: 400, error code: 100005, message: You have exceeded your organization's memory limit: app requested more memory than available
這怎么可能?!
我找到了解決方案; 這是相當出乎意料和違反直覺的。 這是我所做的:
applications:
- instances: 1
timeout: 180
name: appname
buildpack: java_buildpack
path: ./target/appname-1.0-SNAPSHOT.jar
disk_quota: 1G
memory: 192M
domain: eu-gb.mybluemix.net
host: appHost
env:
JAVA_OPTS: '-XX:ReservedCodeCacheSize=32M -XX:MaxDirectMemorySize=32M'
JBP_CONFIG_OPEN_JDK_JRE: '[memory_calculator: {stack_threads: 2}]'
注意:部署后,實例的 memory 被覆蓋並分配 192MB。 為了在代碼中執行任何進一步的更改,我需要在推送更改和部署應用程序之前將 memory 設置回 64MB。
對於 Lite 帳戶,memory 在為帳戶部署的所有應用程序中限制為 256 MB:
https://cloud.ibm.com/docs/account?topic=account-noruntimemem
您將需要停止任何未使用的 Cloud Foundry 應用程序或升級您的帳戶。
在 Cloud Foundry 中,應用程序代碼中的manifest.yml將指定 memory。
注意:如果您使用的是工具鏈,部署將創建一個新應用程序並在管道中的每次重新部署時切換路由,因此暫時您將運行兩個應用程序以避免停機。 這是另一種情況,您可能會遇到此 memory 問題(即您的應用程序指定了 256MB 的 memory 但在兩個應用程序運行時暫時有 512MB 的使用量)。 要解決此問題,請在運行管道之前手動停止正在運行的 CF 應用程序(停止時會導致停機)或升級您的帳戶。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.