From 4359e8fa3018b132ee875c1806c776029754f979 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 4 Oct 2023 14:06:40 +0000 Subject: [PATCH 1/4] fix readme --- HelmChart/Public/oneuptime/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HelmChart/Public/oneuptime/README.md b/HelmChart/Public/oneuptime/README.md index 4afbc0bce0..2503f7ac91 100644 --- a/HelmChart/Public/oneuptime/README.md +++ b/HelmChart/Public/oneuptime/README.md @@ -11,9 +11,9 @@ OneUptime is a comprehensive solution for monitoring and managing your online se ## Install Helm Chart -#### Create values.yaml file and change the default secrets. +#### Create values.yaml file. -Create a values.yaml file and change the default secrets. +Create a values.yaml file and change the host. ```yaml host: From 43069791da6a7adede7498b2e64ba582d86b5ab8 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 4 Oct 2023 18:10:15 +0000 Subject: [PATCH 2/4] add values --- CommonServer/EnvironmentConfig.ts | 38 ++++++++++++++----- .../Public/oneuptime/templates/_helpers.tpl | 2 +- .../Public/oneuptime/templates/home.yaml | 13 ++++--- .../oneuptime/templates/test-server.yaml | 6 ++- HelmChart/Public/oneuptime/values.yaml | 4 ++ 5 files changed, 46 insertions(+), 17 deletions(-) diff --git a/CommonServer/EnvironmentConfig.ts b/CommonServer/EnvironmentConfig.ts index caf214b104..2c1bfa26c1 100644 --- a/CommonServer/EnvironmentConfig.ts +++ b/CommonServer/EnvironmentConfig.ts @@ -62,43 +62,61 @@ export const ClusterKey: ObjectID = new ObjectID( export const HasClusterKey: boolean = Boolean(process.env['ONEUPTIME_SECRET']); export const RealtimeHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_REALTIME_HOSTNAME']}:${process.env['REALTIME_PORT']}` + `${process.env['SERVER_REALTIME_HOSTNAME']}:${ + process.env['REALTIME_PORT'] || 80 + }` ); export const NotificationHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_NOTIFICATION_HOSTNAME']}:${process.env['NOTIFICATION_PORT']}` + `${process.env['SERVER_NOTIFICATION_HOSTNAME']}:${ + process.env['NOTIFICATION_PORT'] || 80 + }` ); export const WorkerHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_WORKERS_HOSTNAME']}:${process.env['WORKERS_PORT']}` + `${process.env['SERVER_WORKERS_HOSTNAME']}:${ + process.env['WORKERS_PORT'] || 80 + }` ); export const LinkShortenerHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_LINK_SHORTENER_HOSTNAME']}:${process.env['LINK_SHORTENER_PORT']}` + `${process.env['SERVER_LINK_SHORTENER_HOSTNAME']}:${ + process.env['LINK_SHORTENER_PORT'] || 80 + }` ); export const WorkflowHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_WORKFLOW_HOSTNAME']}:${process.env['WORKFLOW_PORT']}` + `${process.env['SERVER_WORKFLOW_HOSTNAME']}:${ + process.env['WORKFLOW_PORT'] || 80 + }` ); export const DashboardApiHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_DASHBOARD_API_HOSTNAME']}:${process.env['DASHBOARD_API_PORT']}` + `${process.env['SERVER_DASHBOARD_API_HOSTNAME']}:${ + process.env['DASHBOARD_API_PORT'] || 80 + }` ); export const ProbeApiHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_PROBE_API_HOSTNAME']}:${process.env['PROBE_API_PORT']}` + `${process.env['SERVER_PROBE_API_HOSTNAME']}:${ + process.env['PROBE_API_PORT'] || 80 + }` ); export const AccountsHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_ACCOUNTS_HOSTNAME']}:${process.env['ACCOUNTS_PORT']}` + `${process.env['SERVER_ACCOUNTS_HOSTNAME']}:${ + process.env['ACCOUNTS_PORT'] || 80 + }` ); export const HomeHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_HOME_HOSTNAME']}:${process.env['HOME_PORT']}` + `${process.env['SERVER_HOME_HOSTNAME']}:${process.env['HOME_PORT'] || 80}` ); export const DashboardHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_DASHBOARD_HOSTNAME']}:${process.env['DASHBOARD_PORT']}` + `${process.env['SERVER_DASHBOARD_HOSTNAME']}:${ + process.env['DASHBOARD_PORT'] || 80 + }` ); export const Env: string = process.env['NODE_ENV'] || 'production'; diff --git a/HelmChart/Public/oneuptime/templates/_helpers.tpl b/HelmChart/Public/oneuptime/templates/_helpers.tpl index 9fcc53672c..3053f78e9d 100644 --- a/HelmChart/Public/oneuptime/templates/_helpers.tpl +++ b/HelmChart/Public/oneuptime/templates/_helpers.tpl @@ -137,7 +137,7 @@ - name: REDIS_PASSWORD valueFrom: secretKeyRef: - name: {{ printf "%s-%s" $.Release.Name "redis-password" }} + name: {{ printf "%s-%s" $.Release.Name "redis" }} key: redis-password - name: REDIS_DB value: {{ printf "0" | squote}} diff --git a/HelmChart/Public/oneuptime/templates/home.yaml b/HelmChart/Public/oneuptime/templates/home.yaml index 78f3f44876..ac8dc796c3 100644 --- a/HelmChart/Public/oneuptime/templates/home.yaml +++ b/HelmChart/Public/oneuptime/templates/home.yaml @@ -1,16 +1,19 @@ +{{- if $.Values.billing.enabled }} + # OneUptime home Deployment {{- $homeEnv := dict "PORT" $.Values.port.home -}} {{- $homeDeploymentArgs :=dict "IsUI" true "ServiceName" "home" "Port" $.Values.port.home "Release" $.Release "Values" $.Values "Env" $homeEnv -}} {{- include "oneuptime.deployment" $homeDeploymentArgs }} --- +# OneUptime home autoscaler +{{- $homeAutoScalerArgs := dict "ServiceName" "home" "Release" $.Release "Values" $.Values -}} +{{- include "oneuptime.autoscaler" $homeAutoScalerArgs }} +--- +{{- end }} + # OneUptime home Service {{- $homeServiceArgs := dict "ServiceName" "home" "Port" $.Values.port.home "Release" $.Release "Values" $.Values -}} {{- include "oneuptime.service" $homeServiceArgs }} ---- - -# OneUptime home autoscaler -{{- $homeAutoScalerArgs := dict "ServiceName" "home" "Release" $.Release "Values" $.Values -}} -{{- include "oneuptime.autoscaler" $homeAutoScalerArgs }} --- \ No newline at end of file diff --git a/HelmChart/Public/oneuptime/templates/test-server.yaml b/HelmChart/Public/oneuptime/templates/test-server.yaml index a531478b2e..7d03e24c56 100644 --- a/HelmChart/Public/oneuptime/templates/test-server.yaml +++ b/HelmChart/Public/oneuptime/templates/test-server.yaml @@ -1,3 +1,5 @@ +{{- if $.Values.testServer.enabled }} + # OneUptime testServer Deployment {{- $testServerEnv := dict "PORT" $.Values.port.testServer -}} {{- $testServerDeploymentArgs :=dict "IsUI" true "ServiceName" "test-server" "Port" $.Values.port.testServer "Release" $.Release "Values" $.Values "Env" $testServerEnv -}} @@ -13,4 +15,6 @@ # OneUptime testServer autoscaler {{- $testServerAutoScalerArgs := dict "ServiceName" "test-server" "Release" $.Release "Values" $.Values -}} {{- include "oneuptime.autoscaler" $testServerAutoScalerArgs }} ---- \ No newline at end of file +--- + +{{- end }} \ No newline at end of file diff --git a/HelmChart/Public/oneuptime/values.yaml b/HelmChart/Public/oneuptime/values.yaml index 1be0318669..fd4ebc0905 100644 --- a/HelmChart/Public/oneuptime/values.yaml +++ b/HelmChart/Public/oneuptime/values.yaml @@ -143,3 +143,7 @@ port: adminDashboard: 3158 nginx: 80 haraka: 2525 + + +testServer: + enabled: false \ No newline at end of file From 01b677ec774d0e441d442426558faefc6d332032 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 4 Oct 2023 19:15:20 +0100 Subject: [PATCH 3/4] fix hostnames --- CommonServer/EnvironmentConfig.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/CommonServer/EnvironmentConfig.ts b/CommonServer/EnvironmentConfig.ts index 2c1bfa26c1..2f5989baea 100644 --- a/CommonServer/EnvironmentConfig.ts +++ b/CommonServer/EnvironmentConfig.ts @@ -62,59 +62,61 @@ export const ClusterKey: ObjectID = new ObjectID( export const HasClusterKey: boolean = Boolean(process.env['ONEUPTIME_SECRET']); export const RealtimeHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_REALTIME_HOSTNAME']}:${ + `${process.env['SERVER_REALTIME_HOSTNAME'] || 'localhost'}:${ process.env['REALTIME_PORT'] || 80 }` ); export const NotificationHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_NOTIFICATION_HOSTNAME']}:${ + `${process.env['SERVER_NOTIFICATION_HOSTNAME'] || 'localhost'}:${ process.env['NOTIFICATION_PORT'] || 80 }` ); export const WorkerHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_WORKERS_HOSTNAME']}:${ + `${process.env['SERVER_WORKERS_HOSTNAME'] || 'localhost'}:${ process.env['WORKERS_PORT'] || 80 }` ); export const LinkShortenerHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_LINK_SHORTENER_HOSTNAME']}:${ + `${process.env['SERVER_LINK_SHORTENER_HOSTNAME' || 'localhost']}:${ process.env['LINK_SHORTENER_PORT'] || 80 }` ); export const WorkflowHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_WORKFLOW_HOSTNAME']}:${ + `${process.env['SERVER_WORKFLOW_HOSTNAME'] || 'localhost'}:${ process.env['WORKFLOW_PORT'] || 80 }` ); export const DashboardApiHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_DASHBOARD_API_HOSTNAME']}:${ + `${process.env['SERVER_DASHBOARD_API_HOSTNAME'] || 'localhost'}:${ process.env['DASHBOARD_API_PORT'] || 80 }` ); export const ProbeApiHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_PROBE_API_HOSTNAME']}:${ + `${process.env['SERVER_PROBE_API_HOSTNAME'] || 'localhost'}:${ process.env['PROBE_API_PORT'] || 80 }` ); export const AccountsHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_ACCOUNTS_HOSTNAME']}:${ + `${process.env['SERVER_ACCOUNTS_HOSTNAME'] || 'localhost'}:${ process.env['ACCOUNTS_PORT'] || 80 }` ); export const HomeHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_HOME_HOSTNAME']}:${process.env['HOME_PORT'] || 80}` + `${process.env['SERVER_HOME_HOSTNAME'] || 'localhost'}:${ + process.env['HOME_PORT'] || 80 + }` ); export const DashboardHostname: Hostname = Hostname.fromString( - `${process.env['SERVER_DASHBOARD_HOSTNAME']}:${ + `${process.env['SERVER_DASHBOARD_HOSTNAME'] || 'localhost'}:${ process.env['DASHBOARD_PORT'] || 80 }` ); From 2d4bb56ffa55e59727c0a48a24c0ca2dc42fa9ce Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 4 Oct 2023 19:22:25 +0100 Subject: [PATCH 4/4] exit node process on app init fail --- Accounts/Serve.ts | 2 ++ AdminDashboard/Serve.ts | 2 ++ ApiReference/Index.ts | 2 ++ Dashboard/Serve.ts | 2 ++ DashboardAPI/Index.ts | 2 ++ File/Index.ts | 2 ++ Identity/Index.ts | 2 ++ LinkShortener/Index.ts | 2 ++ Notification/Index.ts | 2 ++ Probe/Index.ts | 2 ++ ProbeAPI/Index.ts | 2 ++ StatusPage/Serve.ts | 2 ++ TestServer/Index.ts | 2 ++ Workers/Index.ts | 2 ++ Workflow/Index.ts | 2 ++ 15 files changed, 30 insertions(+) diff --git a/Accounts/Serve.ts b/Accounts/Serve.ts index bded796593..2fd9bba83a 100755 --- a/Accounts/Serve.ts +++ b/Accounts/Serve.ts @@ -14,11 +14,13 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/AdminDashboard/Serve.ts b/AdminDashboard/Serve.ts index 4ce80126ce..126fe87cc3 100755 --- a/AdminDashboard/Serve.ts +++ b/AdminDashboard/Serve.ts @@ -13,11 +13,13 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/ApiReference/Index.ts b/ApiReference/Index.ts index ffb956c663..dca2747a43 100755 --- a/ApiReference/Index.ts +++ b/ApiReference/Index.ts @@ -93,11 +93,13 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/Dashboard/Serve.ts b/Dashboard/Serve.ts index c3d3775023..49e87c258f 100755 --- a/Dashboard/Serve.ts +++ b/Dashboard/Serve.ts @@ -13,11 +13,13 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/DashboardAPI/Index.ts b/DashboardAPI/Index.ts index 175ccd5baf..f399410d04 100755 --- a/DashboardAPI/Index.ts +++ b/DashboardAPI/Index.ts @@ -1019,10 +1019,12 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/File/Index.ts b/File/Index.ts index 465b553241..a3fc1b47c5 100644 --- a/File/Index.ts +++ b/File/Index.ts @@ -42,10 +42,12 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/Identity/Index.ts b/Identity/Index.ts index e8da10926b..6d0e6265e6 100644 --- a/Identity/Index.ts +++ b/Identity/Index.ts @@ -46,10 +46,12 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/LinkShortener/Index.ts b/LinkShortener/Index.ts index c0e38dd412..4822abe070 100644 --- a/LinkShortener/Index.ts +++ b/LinkShortener/Index.ts @@ -22,11 +22,13 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/Notification/Index.ts b/Notification/Index.ts index 31de57a692..45542eaad4 100644 --- a/Notification/Index.ts +++ b/Notification/Index.ts @@ -41,10 +41,12 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/Probe/Index.ts b/Probe/Index.ts index e2c86f8d26..d670957af3 100644 --- a/Probe/Index.ts +++ b/Probe/Index.ts @@ -49,10 +49,12 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/ProbeAPI/Index.ts b/ProbeAPI/Index.ts index 64d2322792..f69c813164 100644 --- a/ProbeAPI/Index.ts +++ b/ProbeAPI/Index.ts @@ -40,10 +40,12 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/StatusPage/Serve.ts b/StatusPage/Serve.ts index c88062d030..dd191db9b0 100644 --- a/StatusPage/Serve.ts +++ b/StatusPage/Serve.ts @@ -18,11 +18,13 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/TestServer/Index.ts b/TestServer/Index.ts index 54dbf6bdd5..c5bc9a3db2 100644 --- a/TestServer/Index.ts +++ b/TestServer/Index.ts @@ -19,10 +19,12 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/Workers/Index.ts b/Workers/Index.ts index 7cf4516825..9a5497cffe 100644 --- a/Workers/Index.ts +++ b/Workers/Index.ts @@ -121,10 +121,12 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); }); diff --git a/Workflow/Index.ts b/Workflow/Index.ts index a8e6972b47..e006f35f6b 100644 --- a/Workflow/Index.ts +++ b/Workflow/Index.ts @@ -73,11 +73,13 @@ const init: () => Promise = async (): Promise => { } catch (err) { logger.error('App Init Failed:'); logger.error(err); + throw err; } }; init().catch((err: Error) => { logger.error(err); + logger.info('Exiting node process'); process.exit(1); });