Kotlin > Ktor > Auto Reload 사용
설정 파일
application.conf에 다음을 추가합니다.
이 경우에는
/build/classes
가 감시 대상이 된다. application.conf
ktor {
deployment {
port = 8080
port = ${?PORT}
watch = [ classes ]
}
application {
modules = [ com.example.ApplicationKt.module ]
}
development = true
}
watch는 그 밖에도 다음과 같이 설정할 수 있는 모양
watch = [ / ]
watch = [ classes, resources ]
Auto-reload | Ktor
모니터링 작업 시작
terminal에서 다음을 수행하여 소스가 변경되면 다시 빌드해야 합니다.
gradle -t installDist
or (↑どちらかお好きな方で↓)
gradlew -t build
작업이 시작됩니다.
gradle -t installDist
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 765ms
6 actionable tasks: 6 up-to-date
Waiting for changes to input files of tasks... (ctrl-d to exit)
<-------------> 0% WAITING
> IDLE
실행
평소대로 실행한다.
아래와 같이 Watching이 표시되면 OK
2021-08-12 12:46:38.361 [main] DEBUG Application - Java Home: /Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents
2021-08-12 12:46:38.362 [main] DEBUG Application - Class Loader: jdk.internal.loader.ClassLoaders$AppClassLoader
2021-08-12 12:46:38.370 [main] DEBUG Application - Watching /Users/atsu/Downloads/ktor-autoreload/build/classes/kotlin/main/com/example for changes.
2021-08-12 12:46:38.370 [main] DEBUG Application - Watching /Users/atsu/Downloads/ktor-autoreload/build/classes/kotlin/main for changes.
2021-08-12 12:46:38.370 [main] DEBUG Application - Watching /Users/atsu/Downloads/ktor-autoreload/build/classes/kotlin/main/META-INF for changes.
2021-08-12 12:46:38.370 [main] DEBUG Application - Watching /Users/atsu/Downloads/ktor-autoreload/build/classes/kotlin/main/com for changes.
2021-08-12 12:46:38.775 [main] INFO Application - Responding at http://0.0.0.0:8080
변경
소스를 변경하면
gradle -t installDist
가 변경을 감지하고 다시 빌드됩니다.modified: /Users/atsu/Downloads/ktor-autoreload/src/Application.kt
Change detected, executing build...
> Task :compileKotlin
w: /Users/atsu/Downloads/ktor-autoreload/src/Application.kt: (12, 24): Parameter 'testing' is never used
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 850ms
6 actionable tasks: 5 executed, 1 up-to-date
Waiting for changes to input files of tasks... (ctrl-d to exit)
<<=============> 100% EXECUTING [1m 28s]
> IDLE
기타
GraphQL 디버깅에도 유용 할 것 같습니다.
참고
Auto-reload | Ktor
Reference
이 문제에 관하여(Kotlin > Ktor > Auto Reload 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/sugasaki/items/1f023c273871c21e02f1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)