Skip to content

Commit

Permalink
Measure start time n allow space separate
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Jan 4, 2024
1 parent 25e14fc commit 1d1f8cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/executor/nginx.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ class NginxExecutor {
switch (key) {
case "env_var_list":
config.passenger[key].forEach((/** @type {String} */ v) => {
var splt = splitLimit(v, /=/g, 2);
var splt = splitLimit(v, /[= ]/g, 2);
if (splt.length == 2) {
node._add("passenger_env_var", splt[0] + ' ' + escapeNginx(splt[1]));
}
});
continue;
case "set_header_list":
config.passenger[key].forEach((/** @type {String} */ v) => {
var splt = splitLimit(v, /=/g, 2);
var splt = splitLimit(v, /[= ]/g, 2);
if (splt.length == 2) {
node._add("passenger_set_header", splt[0] + ' ' + escapeNginx(splt[1]));
}
Expand Down Expand Up @@ -176,7 +176,7 @@ class NginxExecutor {
for (const env of node[k]) {
var splt = splitLimit(env._value, / /g, 2);
if (splt.length == 2) {
r.passenger["set_header_list"].push(splt[0] + '=' + unescapeNginx(splt[1]));
r.passenger["set_header_list"].push(splt[0] + ' ' + unescapeNginx(splt[1]));
}
}
break;
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import runner from './controllers/runner.js';
import virtualmin from './controllers/virtualmin.js';
import podman from './controllers/podman.js';

const startTime = Date.now();
dotenv.config();
initUtils();

Expand All @@ -36,5 +37,6 @@ app.use(function (err, req, res, next) {
const port = process.env.PORT ? parseInt(process.env.PORT) : 2223;
app.listen(port, function () {
console.log(`Listening on ${port}`);
console.log(`Start time takes ` + (Date.now() - startTime) / 1000 + ` s`)
})

4 changes: 3 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ export const unescapeNginx = function ( /** @type {string} */ str) {
// https://stackoverflow.com/a/64296576
export function splitLimit(/** @type {string} */ input,/** @type {string|RegExp} */ separator, /** @type {Number} */ limit) {
// Ensure the separator is global
separator = new RegExp(separator, 'g');
if (!(separator instanceof RegExp) || !separator.global) {
separator = new RegExp(separator, 'g');
}
// Allow the limit argument to be excluded
limit = limit ?? -1;

Expand Down

0 comments on commit 1d1f8cd

Please sign in to comment.