-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
210 additions
and
9 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
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
32 changes: 32 additions & 0 deletions
32
code/tic-tac-tow-service/src/main/kotlin/pt/isel/daw/tictactow/http/StatusController.kt
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package pt.isel.daw.tictactow.http | ||
|
||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import pt.isel.daw.tictactow.http.model.StatusOutputModel | ||
import pt.isel.daw.tictactow.infra.siren | ||
import pt.isel.daw.tictactow.repository.TransactionManager | ||
import java.net.InetAddress | ||
|
||
@RestController | ||
class StatusController( | ||
val transactionManager: TransactionManager | ||
) { | ||
|
||
@GetMapping(Uris.STATUS) | ||
fun getStatus() = transactionManager.run { transaction -> | ||
siren( | ||
StatusOutputModel( | ||
hostname = System.getenv("HOSTNAME"), | ||
gamesCount = transaction.gamesRepository.count() | ||
) | ||
) { | ||
// For now, nothing more to add. | ||
} | ||
} | ||
|
||
@GetMapping(Uris.STATUS_HOSTNAME) | ||
fun getStatusHostname(): String = System.getenv("HOSTNAME") | ||
|
||
@GetMapping(Uris.STATUS_IP) | ||
fun getStatusIp(): String = InetAddress.getLocalHost().hostAddress | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...tic-tac-tow-service/src/main/kotlin/pt/isel/daw/tictactow/http/model/StatusOutputModel.kt
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package pt.isel.daw.tictactow.http.model | ||
|
||
data class StatusOutputModel( | ||
val hostname: String, | ||
val gamesCount: Int, | ||
) |
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
2 changes: 1 addition & 1 deletion
2
code/tic-tac-tow-service/src/main/resources/application.properties
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 +1 @@ | ||
|
||
server.port=${port:8080} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM openjdk:17 | ||
ARG DEPENDENCY=build/dependency | ||
# first layer with the external libs (i.e. the files that change the least). | ||
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib | ||
# second layer with the 'META-INF' contents. | ||
COPY ${DEPENDENCY}/META-INF /app/META-INF | ||
# last layer with the application JARs (i.e. the files that change the most). | ||
COPY ${DEPENDENCY}/BOOT-INF/classes /app | ||
ENTRYPOINT ["java","-cp","app:app/lib/*","pt.isel.daw.tictactow.TicTacTowApplicationKt"] |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM ubuntu | ||
RUN apt -y update | ||
RUN apt -y install dnsutils |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
|
||
upstream static-spring-service { | ||
server spring-service-1:8081 max_fails=3 fail_timeout=10s; | ||
server spring-service-2:8082 max_fails=3 fail_timeout=10s; | ||
} | ||
|
||
upstream dynamic-spring-service { | ||
server spring-service:8080 max_fails=3 fail_timeout=10s; | ||
} | ||
|
||
server { | ||
listen 8080; | ||
|
||
location / { | ||
proxy_pass http://static-spring-service; | ||
proxy_connect_timeout 5s; | ||
proxy_next_upstream error timeout http_500; | ||
} | ||
} | ||
|
||
server { | ||
listen 8088; | ||
|
||
location / { | ||
proxy_pass http://dynamic-spring-service; | ||
proxy_connect_timeout 5s; | ||
proxy_next_upstream error timeout http_500; | ||
} | ||
} | ||
} |