簡體   English   中英

在Heroku上運行我的應用程序時,為什么會出現啟動超時錯誤(錯誤R10)?

[英]Why do I get a Boot timeout error (Error R10) when running my app on Heroku?

我有一個在Heroku上部署的Java應用程序。 部署就像超級按鈕一樣工作,沒有錯誤或警告,該應用程序開始運行。 但是,一段時間后,出現以下錯誤:

錯誤R10(引導超時)-> Web進程在啟動后90秒內未能綁定到$ PORT

我在本地運行我的應用程序時沒有任何錯誤。

僅供參考:此應用會定期檢查postgresql數據庫中的表是否進行了更改,如果是,則更新同一數據庫中的另一個表(據我所知,這與我的問題沒有太大關系,但是您可以)。

這是日志:

2019-02-12T19:37:15.444651+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=24637 -cp target/classes:target/dependency/* com.name.numbersbackend.Main`
2019-02-12T19:37:18.657701+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2019-02-12T19:37:18.660650+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 
2019-02-12T19:37:35.580329+00:00 app[web.1]: .
2019-02-12T19:37:51.105807+00:00 app[web.1]: .
2019-02-12T19:38:06.683974+00:00 app[web.1]: .
2019-02-12T19:38:22.198062+00:00 app[web.1]: .
2019-02-12T19:38:37.792613+00:00 app[web.1]: .
2019-02-12T19:38:45.489753+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2019-02-12T19:38:45.489753+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-02-12T19:38:45.663859+00:00 heroku[web.1]: Process exited with status 137
2019-02-12T19:38:45.682773+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-12T19:38:45.766843+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-12T19:38:48.871480+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=39010 -cp target/classes:target/dependency/* com.name.numbersbackend.Main`
2019-02-12T19:38:51.074950+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2019-02-12T19:38:51.077995+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 
2019-02-12T19:39:07.724633+00:00 app[web.1]: .
2019-02-12T19:39:23.250203+00:00 app[web.1]: .
2019-02-12T19:39:38.760492+00:00 app[web.1]: .
2019-02-12T19:39:54.313859+00:00 app[web.1]: .
2019-02-12T19:40:09.881207+00:00 app[web.1]: .
2019-02-12T19:40:19.374407+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-12T19:40:19.187236+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2019-02-12T19:40:19.187351+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-02-12T19:40:19.354497+00:00 heroku[web.1]: Process exited with status 137

僅供參考:該行2019-02-12T19:39:38.760492+00:00 app[web.1]: . (和類似的行)包含我的應用程序的一些臨時輸出,以表明它實際上在做某事。 對於這些行中的每行,程序都在檢查表是否存在更改,如果有更改,是否需要采取措施(如果需要采取措施,則應用程序的輸出更有意義)。

如您所見,該應用程序可以正常啟動,運行一段時間,然后崩潰甚至重啟。 但是,有時它會完全停止工作。

這是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.name</groupId>
    <artifactId>com.name.app.backend</artifactId>
    <version>1.0</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.json/json -->
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20180813</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.5</version>
        </dependency>
        <dependency>
            <groupId>com.github.myname</groupId>
            <artifactId>app-lib</artifactId>
            <version>master-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

...和我的Procfile:

web: java $JAVA_OPTS -Dserver.port=$PORT -cp target/classes:target/dependency/* nl.limakajo.numbersbackend.Main

經過大量Google搜索和SO瀏覽后,我沒有找到解決方案。

聽起來您希望此過程在后台運行而不處理Web請求。 如果是這種情況,則您不想在Procfile使用web: Procfile 在Heroku上,對web進程進行了特殊處理:為其分配了PORT env var,必須在啟動后的90秒鍾內將其綁定。

我建議將您的Procfile更改為:

worker: java $JAVA_OPTS -cp target/classes:target/dependency/* nl.limakajo.numbersbackend.Main

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM