Skip to content
Snippets Groups Projects
Commit a5082ebc authored by Simon Döring's avatar Simon Döring
Browse files

Merge branch 'master' into neopult-dev

parents 4fb91686 5bfb3339
Branches
No related tags found
No related merge requests found
...@@ -65,6 +65,8 @@ Once the code is compiled, the server can be started with `node server.js` in th ...@@ -65,6 +65,8 @@ Once the code is compiled, the server can be started with `node server.js` in th
The camera server can read a path to a config file from the `CONFIG_PATH` environment variable. The camera server can read a path to a config file from the `CONFIG_PATH` environment variable.
This config file has to be in the json format and should have [this structure](./camera-server/example-config.json). This config file has to be in the json format and should have [this structure](./camera-server/example-config.json).
Additionally each config key can be overwritten with an environment variable `CVH_CAMERA_CONFIG_<key>` (e.g. `CVH_CAMERA_CONFIG_cameraSlots` to overwrite the numbers of camera slots).
Below is a description of the config file's properties: Below is a description of the config file's properties:
* `port`: The port on which the server will listen. Defaults to `5000`. * `port`: The port on which the server will listen. Defaults to `5000`.
......
{
"tabWidth": 4,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "none"
}
...@@ -84,6 +84,33 @@ if (fileContent) { ...@@ -84,6 +84,33 @@ if (fileContent) {
} }
} }
const ENV_CONFIG_PREFIX = 'CVH_CAMERA_CONFIG_';
Object.keys(process.env).forEach((envKey) => {
if (envKey.startsWith(ENV_CONFIG_PREFIX)) {
const configKey = envKey.slice(ENV_CONFIG_PREFIX.length);
if (indexableConfig.hasOwnProperty(configKey)) {
const expectedType = typeof indexableConfig[configKey];
if (expectedType === 'string') {
indexableConfig[configKey] = process.env[envKey]!;
} else if (expectedType === 'number') {
const envValue = process.env[envKey]!;
const num = parseInt(envValue);
if (!isNaN(num)) {
indexableConfig[configKey] = num;
} else {
console.log(
`Error: Config key ${configKey} from environment could not be parsed to a number`
);
}
}
} else {
console.log(
`Error: Unknown config key ${configKey} in environment`
);
}
}
});
const config = indexableConfig as Config; const config = indexableConfig as Config;
if (config.notifyPath && !path.isAbsolute(config.notifyPath) && configPath) { if (config.notifyPath && !path.isAbsolute(config.notifyPath) && configPath) {
config.notifyPath = path.resolve( config.notifyPath = path.resolve(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment