# How to use ktor auto reload (live refresh) that using gradle kotlin dsl?

**URL:** <https://discuss.kotlinlang.org/t/how-to-use-ktor-auto-reload-live-refresh-that-using-gradle-kotlin-dsl/17638>\
**Category:** Web Development\
**Created:** [May 13, 2020, 3:09am UTC](https://discuss.kotlinlang.org/t/how-to-use-ktor-auto-reload-live-refresh-that-using-gradle-kotlin-dsl/17638 "2020-05-13T03:09:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sombochea](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sombochea/32/7045_2.png) [@sombochea](https://discuss.kotlinlang.org/u/sombochea)\
**Post date:** [May 13, 2020, 3:09am UTC](https://discuss.kotlinlang.org/t/how-to-use-ktor-auto-reload-live-refresh-that-using-gradle-kotlin-dsl/17638/1 "2020-05-13T03:09:48Z")

</div>

I want to develop server and client web with ktor, but when coding I don’t want to restart application every time. How could I do with this option?

This main application:  
`fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)`

Kotlin version: 1.3.70  
Ktor version: 1.3.2

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [May 13, 2020, 3:47pm UTC](https://discuss.kotlinlang.org/t/how-to-use-ktor-auto-reload-live-refresh-that-using-gradle-kotlin-dsl/17638/2 "2020-05-13T15:47:12Z")

</div>

first result on google: [https://ktor.io/servers/autoreload.html](https://ktor.io/servers/autoreload.html)

---

<div class="post-metadata">

**Author:** ![sombochea](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sombochea/32/7045_2.png) [@sombochea](https://discuss.kotlinlang.org/u/sombochea)\
**Post date:** [May 14, 2020, 1:46am UTC](https://discuss.kotlinlang.org/t/how-to-use-ktor-auto-reload-live-refresh-that-using-gradle-kotlin-dsl/17638/3 "2020-05-14T01:46:45Z")

</div>

Thank you!

As that, I need to apply my main function following this block below!

```auto
fun main(args: Array<String>) {
    embeddedServer(
        Netty,
        watchPaths = listOf("solutions/exercise4"),
        port = 8080,
        module = Application::mymodule
    ).apply { start(wait = true) }
}

fun Application.mymodule() {
    routing {
        get("/plain") {
            call.respondText("Hello World!")
        }
    }
}

```

Because my original main block is like that,

```auto
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

```

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [May 14, 2020, 2:03am UTC](https://discuss.kotlinlang.org/t/how-to-use-ktor-auto-reload-live-refresh-that-using-gradle-kotlin-dsl/17638/4 "2020-05-14T02:03:27Z")

</div>

It’s there under [Using the `application.conf`](https://ktor.io/servers/autoreload.html#configuration-file)

---

<div class="post-metadata">

**Author:** ![sombochea](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sombochea/32/7045_2.png) [@sombochea](https://discuss.kotlinlang.org/u/sombochea)\
**Post date:** [May 14, 2020, 5:56am UTC](https://discuss.kotlinlang.org/t/how-to-use-ktor-auto-reload-live-refresh-that-using-gradle-kotlin-dsl/17638/5 "2020-05-14T05:56:34Z")

</div>

Yes, I was config it too in application.conf
