feat: add basic health check server

This commit is contained in:
Jonathan Barrow 2026-01-16 16:27:39 -05:00
parent 803ccf46b5
commit 6fee83c989
No known key found for this signature in database
GPG Key ID: 2A7DAA6DED5A77E5
2 changed files with 21 additions and 14 deletions

View File

@ -84,15 +84,16 @@ All configuration options are handled via environment variables
`.env` files are supported
| Name | Description | Required |
|---------------------------------------------|------------------------------------------------------------------------------------------------------------------------|-------------------------------------|
| `PN_FRIENDS_CONFIG_DATABASE_URI` | Fully qualified URI to your Postgres server (Example `postgres://username:password@localhost/friends?sslmode=disable`) | Yes |
| `PN_FRIENDS_CONFIG_AES_KEY` | AES key used in tokens provided by the account server | Yes |
| `PN_FRIENDS_CONFIG_GRPC_API_KEY` | API key for your GRPC server | No (Assumed to be an open gRPC API) |
| `PN_FRIENDS_GRPC_SERVER_PORT` | Port for the GRPC server | Yes |
| `PN_FRIENDS_AUTHENTICATION_SERVER_PORT` | Port for the authentication server | Yes |
| `PN_FRIENDS_SECURE_SERVER_HOST` | Host name for the secure server (should point to the same address as the authentication server) | Yes |
| `PN_FRIENDS_SECURE_SERVER_PORT` | Port for the secure server | Yes |
| `PN_FRIENDS_ACCOUNT_GRPC_HOST` | Host name for your account server gRPC service | Yes |
| `PN_FRIENDS_ACCOUNT_GRPC_PORT` | Port for your account server gRPC service | Yes |
| `PN_FRIENDS_ACCOUNT_GRPC_API_KEY` | API key for your account server gRPC service | No (Assumed to be an open gRPC API) |
| Name | Description | Required |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `PN_FRIENDS_CONFIG_DATABASE_URI` | Fully qualified URI to your Postgres server (Example `postgres://username:password@localhost/friends?sslmode=disable`) | Yes |
| `PN_FRIENDS_CONFIG_AES_KEY` | AES key used in tokens provided by the account server | Yes |
| `PN_FRIENDS_CONFIG_GRPC_API_KEY` | API key for your GRPC server | No (Assumed to be an open gRPC API) |
| `PN_FRIENDS_GRPC_SERVER_PORT` | Port for the GRPC server | Yes |
| `PN_FRIENDS_AUTHENTICATION_SERVER_PORT` | Port for the authentication server | Yes |
| `PN_FRIENDS_SECURE_SERVER_HOST` | Host name for the secure server (should point to the same address as the authentication server) | Yes |
| `PN_FRIENDS_SECURE_SERVER_PORT` | Port for the secure server | Yes |
| `PN_FRIENDS_ACCOUNT_GRPC_HOST` | Host name for your account server gRPC service | Yes |
| `PN_FRIENDS_ACCOUNT_GRPC_PORT` | Port for your account server gRPC service | Yes |
| `PN_FRIENDS_ACCOUNT_GRPC_API_KEY` | API key for your account server gRPC service | No (Assumed to be an open gRPC API) |
| `PN_FRIENDS_CONFIG_HEALTH_CHECK_PORT` | Port for the basic UDP health check server | No |

View File

@ -11,7 +11,13 @@ import (
var serverBuildString string
func StartAuthenticationServer() {
port, _ := strconv.Atoi(os.Getenv("PN_FRIENDS_AUTHENTICATION_SERVER_PORT"))
prudpPort, _ := strconv.Atoi(os.Getenv("PN_FRIENDS_AUTHENTICATION_SERVER_PORT"))
healthCheckPortString := os.Getenv("PN_FRIENDS_CONFIG_HEALTH_CHECK_PORT")
if healthCheckPortString != "" {
healthCheckPort, _ := strconv.Atoi(healthCheckPortString)
go nex.EnableBasicUDPHealthCheck(healthCheckPort)
}
globals.AuthenticationServer = nex.NewPRUDPServer()
globals.AuthenticationEndpoint = nex.NewPRUDPEndPoint(1)
@ -27,5 +33,5 @@ func StartAuthenticationServer() {
globals.AuthenticationServer.SessionKeyLength = 16
globals.AuthenticationServer.AccessKey = "ridfebb9"
globals.AuthenticationServer.BindPRUDPEndPoint(globals.AuthenticationEndpoint)
globals.AuthenticationServer.Listen(port)
globals.AuthenticationServer.Listen(prudpPort)
}