Skip to content

Commit

Permalink
Merge pull request #1 from arieldossantos/heroku-deploy
Browse files Browse the repository at this point in the history
add heroku deploy
  • Loading branch information
Ariel Reis authored Nov 14, 2020
2 parents f3433cd + 7c19971 commit 6384b43
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: java -jar build/libs/cuddlytrain.jar
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ dependencies {


task stage {
dependsOn build
dependsOn jar
}
15 changes: 14 additions & 1 deletion src/main/kotlin/io/github/arieldossantos/cuddlytrain/Server.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.github.arieldossantos.cuddlytrain.responses.ErrorResponse
import io.ktor.gson.gson
import java.lang.Integer.parseInt
import java.text.DateFormat

/**
Expand Down Expand Up @@ -71,11 +72,23 @@ fun Application.module() {
}
}

/**
* Get port from env or default
*/
private fun getPort(): Int {
val port = System.getenv("PORT")
return if (!port.isNullOrEmpty()) {
parseInt(port)
} else {
8080
}
}

//Main function of server :)
fun main() {
embeddedServer(
Netty,
port = 8080,
port = getPort(),
module = Application::module
).start()
}

0 comments on commit 6384b43

Please sign in to comment.