3 کامیت‌ها 420bd21377 ... 3df2e7a9d1

نویسنده SHA1 پیام تاریخ
  herlanS_ 3df2e7a9d1 port set with env 3 سال پیش
  herlanS_ 146a805e2e add startup health cek 3 سال پیش
  herlanS_ 74a6902983 add startup health cek 3 سال پیش

+ 3 - 0
.gitignore

@@ -1,8 +1,11 @@
 HELP.md
+health
 target/
 !.mvn/wrapper/maven-wrapper.jar
 !**/src/main/**
 !**/src/test/**
+*.zip
+conf/general.ini
 
 ### STS ###
 .apt_generated

conf/general.ini → conf/general-example.ini


+ 15 - 10
src/main/kotlin/co/id/datacomsolusindo/ipphonebridge/IpPhoneBridgeApplication.kt

@@ -9,7 +9,6 @@ import org.springframework.scheduling.annotation.EnableScheduling
 import java.io.File
 import java.io.Serializable
 import java.util.*
-import kotlin.system.exitProcess
 
 
 @SpringBootApplication
@@ -19,17 +18,23 @@ class IpPhoneBridgeApplication
 fun main(args: Array<String>) {
     TimeZone.setDefault(TimeZone.getTimeZone("Asia/Jakarta"))
     val properties = Properties()
-    val confFile = File("conf/general.ini")
-    if (confFile.exists()) {
-        val ini = Wini(File("conf/general.ini"))
-        properties["server.port"] = ini.get("server", "port")
-    } else {
-        properties["server.port"] = System.getenv("PORT")
-    }
-    if (properties["server.port"] == null) {
-        exitProcess(1)
+    val iniFIle = File("conf/general.ini")
+
+    properties["server.port"] = when {
+        System.getenv("PORT") != null -> {
+            System.getenv("PORT")
+        }
+        iniFIle.exists() -> {
+            val ini = Wini(iniFIle)
+            ini.get("server", "port") ?: "9090"
+        }
+        else -> {
+            "9090"
+        }
     }
 
+
+
     val sApp = SpringApplication(IpPhoneBridgeApplication::class.java)
 
     sApp.setDefaultProperties(properties)

+ 5 - 0
src/main/kotlin/co/id/datacomsolusindo/ipphonebridge/WebSocketEventListener.kt

@@ -20,6 +20,11 @@ import java.time.format.DateTimeFormatter
 class WebSocketEventListener {
     @EventListener(ApplicationReadyEvent::class)
     fun doSomethingAfterStartup() {
+        val yourFile = File("health")
+        yourFile.createNewFile()
+        println("file created")
+        println(yourFile.path)
+        println(yourFile.name)
         logBuilder()
     }