-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Step 1: Setting up a basic web server
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory | ||
import javax.ws.rs.core.UriBuilder | ||
|
||
fun main(args: Array<String>) { | ||
println("Hello World") | ||
} | ||
val url = UriBuilder.fromUri("http://0.0.0.0/") | ||
.port(8080) | ||
.build() | ||
|
||
val httpServer = GrizzlyHttpServerFactory.createHttpServer( | ||
url, | ||
true | ||
) | ||
|
||
if (System.getenv()["SHUTDOWN_TYPE"].equals("INPUT")) { | ||
println("Press any key to shutdown") | ||
readLine() | ||
println("Shutting down from input") | ||
httpServer.shutdownNow() | ||
} else { | ||
Runtime.getRuntime().addShutdownHook(Thread { | ||
println("Shutting down from shutdown hook") | ||
httpServer.shutdownNow() | ||
}) | ||
|
||
println("Press Ctrl+C to shutdown") | ||
Thread.currentThread().join() | ||
} | ||
} |