I just deployed my app to heroku, and I’ve created...
# ktor
m
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
ktor-server-netty
is not packaged for some reason
m
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
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
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
What is
scripts/myapp
?
m
that’s the script that is generated
because of the
stage
gradle task
if I run it, there’s a generated script there
c
Most likely it doesn't include dependencies jars
you probably need a far jar, not sure how to make stage task use it
m
interesting
c
m
I was reading a tutorial to generate the jar, from a docker file..
c
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
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