Skip to content

Commit

Permalink
fix: resourceStartingTolerance being saved as string
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Apr 30, 2023
1 parent 0e0a0cf commit 42f7ef0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions core/components/ConfigVault.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ export default class ConfigVault {
if (out.global.language === 'pt_PT' || out.global.language === 'pt_BR') {
out.global.language = 'pt';
}

//Fixing resourceStartingTolerance being saved as string
if (typeof out.monitor.resourceStartingTolerance === 'string') {
out.monitor.resourceStartingTolerance = parseInt(out.monitor.resourceStartingTolerance);
if (isNaN(out.monitor.resourceStartingTolerance)) {
out.monitor.resourceStartingTolerance = 120;
}
}
} catch (error) {
console.verbose.dir(error);
throw new Error(`Malformed configuration file! Make sure your txAdmin is updated!\nOriginal error: ${error.message}`);
Expand Down
7 changes: 6 additions & 1 deletion core/webroutes/settings/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,14 @@ async function handleMonitor(ctx: Context) {
//Prepare body input
let cfg = {
restarterSchedule: ctx.request.body.restarterSchedule.split(',').map((x: string) => x.trim()),
resourceStartingTolerance: ctx.request.body.resourceStartingTolerance,
resourceStartingTolerance: parseInt(ctx.request.body.resourceStartingTolerance),
};

//Checking if resourceStartingTolerance is valid integer
if (typeof cfg.resourceStartingTolerance !== 'number' || isNaN(cfg.resourceStartingTolerance)) {
return ctx.send({ type: 'danger', message: 'resourceStartingTolerance must be a number.' });
}

//Validating restart times
const { valid: validRestartTimes, invalid: invalidRestartTimes } = parseSchedule(cfg.restarterSchedule);
if (invalidRestartTimes.length) {
Expand Down
8 changes: 4 additions & 4 deletions web/main/settings.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@
</label>
<div class="col-sm-9">
<select class="form-control" id="frmMonitor-resourceStartingTolerance" <%= readOnly ? 'disabled' : '' %>>
<option value="90" <%= monitor.resourceStartingTolerance === '90' ? 'selected' : '' %>>1.5 minutes (default)</option>
<option value="180" <%= monitor.resourceStartingTolerance === '180' ? 'selected' : '' %>>3 minutes</option>
<option value="300" <%= monitor.resourceStartingTolerance === '300' ? 'selected' : '' %>>5 minutes</option>
<option value="600" <%= monitor.resourceStartingTolerance === '600' ? 'selected' : '' %>>10 minutes</option>
<option value="90" <%= monitor.resourceStartingTolerance === 90 ? 'selected' : '' %>>1.5 minutes (default)</option>
<option value="180" <%= monitor.resourceStartingTolerance === 180 ? 'selected' : '' %>>3 minutes</option>
<option value="300" <%= monitor.resourceStartingTolerance === 300 ? 'selected' : '' %>>5 minutes</option>
<option value="600" <%= monitor.resourceStartingTolerance === 600 ? 'selected' : '' %>>10 minutes</option>
</select>
<span class="form-text text-muted">
At server boot, how much time to wait for any single resource to start before restarting the server. <br>
Expand Down

0 comments on commit 42f7ef0

Please sign in to comment.