【问题标题】:Deploy a SpringBoot / Angular 4 on Google App Engine with maven使用 maven 在 Google App Engine 上部署 SpringBoot / Angular 4
【发布时间】:2018-05-29 13:17:21
【问题描述】:

我尝试在 GoogleCloud 上部署一个应用程序(目前是免费帐户)。 FrontEnd (Angular) 和 BackEnd (Java/JPA/SpringBoot) 是使用 maven 在单个 .jar 中构建的。

在本地,使用 Jenkins 和 Google Shell 在我的服务器上:

mvn spring-boot:run => 工作正常

但是当我尝试部署时

mvn appengine:deploy => 502 错误

部署标记为成功。但是当我检查日志时(gcloud app logs tail -s default)SpringBoot部署似乎冻结,重新启动,再次冻结,...... 是什么让我发疯......有时它正在工作......在 SpringBoot 再次重新启动前几分钟。

所以,我需要一些建议来找出问题所在。

这是我的 pom.xml

https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">

<modelVersion>4.0.0</modelVersion>

<artifactId>back-office</artifactId>
<name>back-office</name>
<description>Back Office</description>

<parent>
    <groupId>fr.test</groupId>
    <artifactId>mon-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf</groupId>
        <artifactId>thymeleaf-spring4</artifactId>
    </dependency>
    <dependency>
        <groupId>nz.net.ultraq.thymeleaf</groupId>
        <artifactId>thymeleaf-layout-dialect</artifactId>
    </dependency>
    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>6.1.0</version>
    </dependency>
    <!-- BOOT -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- PERSISTENCE -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <!-- SECURITY -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>com.nimbusds</groupId>
        <artifactId>nimbus-jose-jwt</artifactId>
        <version>4.39.2</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>fr.test</groupId>
        <artifactId>front-office</artifactId>
        <version>${project.version}</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

<repositories>
  ....
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>1.3.1</version>
      </plugin>
    </plugins>
</build>

这是我的 app.yaml 配置(在 src/main/appengine 中)

# [START runtime]
runtime: java
env: flex

handlers:
- url: /.*
  script: this field is required, but ignored

runtime_config:  # Optional
  jdk: openjdk8
 # server: jetty9

manual_scaling:
  instances: 1
# [END runtime]

【问题讨论】:

    标签: angular maven google-app-engine spring-boot google-cloud-platform


    【解决方案1】:

    根据您描述的症状,我怀疑您的应用程序容器内存不足并被 OOM 杀手杀死。

    默认的 Flex VM 只有 1GB 的内存,只剩下 600MB 留给应用容器。

    判断内存问题的一个可靠方法是在 Google Cloud Logging UI 的 vm.syslog 中找到类似的内容。

    kernel: [  133.706951] Out of memory: Kill process 4490 (java) score 878 or sacrifice child 
    kernel: [  133.714468] Killed process 4306 (java) total-vm:5332376kB, anon-rss:2712108kB, file-rss:0k
    

    尝试通过将其添加到您的 app.yaml 来增加内存:

    resources:
      memory_gb: 4
    

    【讨论】:

    • 你是对的。这是内存不足。感谢您的回答和解释!
    猜你喜欢
    • 1970-01-01
    • 2023-03-02
    • 1970-01-01
    • 1970-01-01
    • 2016-11-06
    • 2020-08-18
    • 1970-01-01
    • 2013-11-06
    • 2012-02-11
    相关资源
    最近更新 更多