https://kotlinlang.org logo
#ktor
Title
# ktor
m

Manuel Lorenzo

09/18/2019, 3:46 PM
I just deployed my app to heroku, and I’ve created a
Procfile
that points where the scripts are,
web: ./build/scripts/myapp
but I still see if I run
heroku logs --tail
this:
Copy code
2019-09-18T15:43:48.000000+00:00 app[api]: Build started by user <mailto:me@gmail.com|me@gmail.com>
2019-09-18T15:44:43.005061+00:00 heroku[web.1]: State changed from crashed to starting
2019-09-18T15:44:42.815943+00:00 app[api]: Release v12 created by user <mailto:me@gmail.com|me@gmail.com>
2019-09-18T15:44:42.815943+00:00 app[api]: Deploy c26b0ff0 by user <mailto:me@gmail.com|me@gmail.com>
2019-09-18T15:44:46.857033+00:00 heroku[web.1]: Starting process with command `./build/scripts/myapp`
2019-09-18T15:44:48.994734+00:00 heroku[web.1]: State changed from starting to crashed
2019-09-18T15:44:48.978657+00:00 heroku[web.1]: Process exited with status 1
2019-09-18T15:44:48.764617+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2019-09-18T15:44:48.780285+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2019-09-18T15:44:48.927548+00:00 app[web.1]: Error: Could not find or load main class io.ktor.server.netty.EngineMain
2019-09-18T15:45:15.000000+00:00 app[api]: Build succeeded
c

cy

09/18/2019, 3:47 PM
ktor-server-netty
is not packaged for some reason
m

Manuel Lorenzo

09/18/2019, 3:49 PM
what do you mean packaged?
is it correct that in my
build.gradle
I should have
Copy code
apply plugin: 'kotlin'
apply plugin: 'application'

mainClassName = "io.ktor.server.netty.EngineMain"
?
or in the mainClassName I should have my main class?
c

cy

09/18/2019, 3:51 PM
Well, it depends
You may do both
If you have your own main (not module main) - use it
so do you have
ktor-server-netty
dependency? Do you use application.conf?
m

Manuel Lorenzo

09/18/2019, 3:52 PM
well I have
fun main(args: Array<String>): Unit = EngineMain.main(args)
I have the
ktor-server-netty
dependency
Copy code
ktor {
    deployment {
        port = 8080
        port = ${?PORT}
    }
    application {
        modules = [me.manulorenzo.myApp.main]
    }
}
c

cy

09/18/2019, 3:53 PM
What is
scripts/myapp
?
m

Manuel Lorenzo

09/18/2019, 3:54 PM
that’s the script that is generated
because of the
stage
gradle task
if I run it, there’s a generated script there
c

cy

09/18/2019, 3:55 PM
Most likely it doesn't include dependencies jars
you probably need a far jar, not sure how to make stage task use it
m

Manuel Lorenzo

09/18/2019, 3:57 PM
interesting
c

cy

09/18/2019, 3:57 PM
m

Manuel Lorenzo

09/18/2019, 3:57 PM
I was reading a tutorial to generate the jar, from a docker file..
c

cy

09/18/2019, 3:58 PM
after building a fat-jar you need to specify somehow a path to the jar
but it doesn't describe how to use stage task, sorry
Ah I see, it looks like
stage
task can use
Procfile
, so simply specify a path to a fat-jar inside of the file
The other reason could be that you have wrong dependency scope so it's not added to runtime classpath
m

Manuel Lorenzo

09/18/2019, 4:07 PM
I got it working 🙂
👍🏻 1
it looks like the Procfile’s content should point to
./build/install/myapp/bin/myapp
, but for some reason that folder was never built
thanks a lot Sergey
22 Views