Kotlin 将ktor应用程序部署到Heroku后日志中出现错误
我已经用ktor构建了一个测试应用程序,它在我的本地主机上运行良好,但是当我将它上传到heroku并处理它时,它显示构建成功,但当我打开链接时,它显示应用程序错误Kotlin 将ktor应用程序部署到Heroku后日志中出现错误,kotlin,ktor,Kotlin,Ktor,我已经用ktor构建了一个测试应用程序,它在我的本地主机上运行良好,但是当我将它上传到heroku并处理它时,它显示构建成功,但当我打开链接时,它显示应用程序错误 这是我的应用程序类: 这是我的文件: *这是我的格拉德尔: buildscript { repositories { jcenter() } dependencies { classpath "org.jetbrains.kotlin:kotlin
- 这是我的应用程序类:
- 这是我的文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'
group 'ktor.api.com'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
mainClassName = "io.ktor.server.netty.EngineMain"
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
sourceSets {
main.kotlin.srcDirs = main.java.srcDirs = ['src']
test.kotlin.srcDirs = test.java.srcDirs = ['test']
main.resources.srcDirs = ['resources']
test.resources.srcDirs = ['testresources']
}
task stage {
dependsOn installDist
println "Running Stage"
}
repositories {
mavenLocal()
jcenter()
maven { url 'https://kotlin.bintray.com/ktor' }
maven { url 'https://kotlin.bintray.com/kotlin-js-wrappers' }
maven { url "https://plugins.gradle.org/m2/" }
maven {url 'https://jitpack.io'}
maven {url 'https://github.com/psiegman/mvn-repo/raw/master/releases'}
maven {url 'http://dl.bintray.com/kotlin/kotlinx.html'}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"
implementation "ch.qos.logback:logback-classic:$logback_version"
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-jackson:$ktor_version"
implementation "io.ktor:ktor-gson:$ktor_version"
implementation "io.ktor:ktor-auth:$ktor_version"
implementation "io.ktor:ktor-html-builder:$ktor_version"
implementation "org.jetbrains:kotlin-css-jvm:1.0.0-pre.31-kotlin-1.2.41"
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "io.ktor:ktor-client-apache:$ktor_version"
testImplementation "io.ktor:ktor-server-tests:$ktor_version"
}
- 这是连接到heroku帐户并获取日志后,我的cmd出现的错误
PS:我部署我的ktor应用程序的方式是简单地创建一个git并提交我的文件,然后在heroku网站内,我创建一个应用程序并连接到我的github并部署该应用程序,任何帮助都将不胜感激。谢谢各位。我刚刚解决了同样的问题 “kotlinserver”是一个错误的名称,我在控制台中运行了gradlew stage并转到Procfile(build/install/…)中指定的路径来检查它 我认为正确的名称是项目(模块)名称 我也想提几件事
- 首先,
文件中的application.conf
将接收系统环境变量值,因此您不需要在应用程序模块函数中处理${PORT}
。在val PORT=system.getenv(“PORT”)?.toInt():23567
中添加两行,例如下面的application.conf
port=8080
将端口设置为8080,然后设置为SystemEnv端口(如果存在)port=${?port}
- 第二,提醒一下,别忘了为你的应用程序运行
(你也可以在heroku ps:scale web=1
web=1
ktor {
deployment {
environment = development
port = ${PORT}
}
application {
modules = [ ktor.api.com.ApplicationKt.module ]
}
}
web: build/install/kotlinserver/bin/kotlinserver
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'
group 'ktor.api.com'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
mainClassName = "io.ktor.server.netty.EngineMain"
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
sourceSets {
main.kotlin.srcDirs = main.java.srcDirs = ['src']
test.kotlin.srcDirs = test.java.srcDirs = ['test']
main.resources.srcDirs = ['resources']
test.resources.srcDirs = ['testresources']
}
task stage {
dependsOn installDist
println "Running Stage"
}
repositories {
mavenLocal()
jcenter()
maven { url 'https://kotlin.bintray.com/ktor' }
maven { url 'https://kotlin.bintray.com/kotlin-js-wrappers' }
maven { url "https://plugins.gradle.org/m2/" }
maven {url 'https://jitpack.io'}
maven {url 'https://github.com/psiegman/mvn-repo/raw/master/releases'}
maven {url 'http://dl.bintray.com/kotlin/kotlinx.html'}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"
implementation "ch.qos.logback:logback-classic:$logback_version"
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-jackson:$ktor_version"
implementation "io.ktor:ktor-gson:$ktor_version"
implementation "io.ktor:ktor-auth:$ktor_version"
implementation "io.ktor:ktor-html-builder:$ktor_version"
implementation "org.jetbrains:kotlin-css-jvm:1.0.0-pre.31-kotlin-1.2.41"
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "io.ktor:ktor-client-apache:$ktor_version"
testImplementation "io.ktor:ktor-server-tests:$ktor_version"
}
// it show this error related to procfile
bash: build/install/kotlinserver/bin/kotlinserver: No such file or directory
//and this is H10 error code
2020-09-19T12:38:18.476773+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=aqueous-reaches-02639.herokuapp.com request_id=0dbb86c9-0bf1-4aac-acd6-0825c938b3ba fwd="41.200.180.139" dyno= connect= service= status=503 bytes= protocol=https
2020-09-19T12:38:19.256239+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=aqueous-reaches-02639.herokuapp.com request_id=d8bf7249-4f8a-4423-889a-81baca206ba4 fwd="41.200.180.139" dyno= connect= service= status=503 bytes= protocol=https