HFS_ENV_BOOTSTRAP
Massimo Melina committed
Jul 5, 2024 at 18:59 UTC
03b68765b7ba9ac7bc99681768559ec65989c474
2 files changed
+6
-3
config.md
+4
-2
@@ -27,13 +27,15 @@ config config.yaml
27
28
Configuration can be done in several ways
29
- accessing the Admin-panel with your browser
30
- - it will automatically open when you start HFS. Bookmark it. if your port is 8000 the address will be http://localhost:8000/~/admin
30
+ - it will automatically open when you start HFS. Bookmark it.
31
+ If your port is 8000 the address will be http://localhost:8000/~/admin
32
- passing via command line at start in the form `--NAME VALUE`
32
-- using envs in the form `HFS_NAME` (eg: `HFS_PORT`)
33
+- using envs in the form `HFS_<uppercase property name>`, like `HFS_PORT=80` if you want to change the config `port`, but same applies to any other config available,
34
- directly editing the `config.yaml` file. As soon as you save it is reloaded and changes are applied
35
- if you don't want to use an editor, consider typing this (example) command inside the folder where the config file is:
36
`echo "port: 1080" >> config.yaml`
37
- after HFS has started you can enter console command in the form `config NAME VALUE`
38
+- setting special env `HFS_ENV_BOOTSTRAP=true` will disable other envs when file config.yaml already exists.
39
40
`NAME` stands for the property name that you want to change. See the complete list below.
41
src/config.ts
+2
-1
@@ -111,9 +111,10 @@ export function getWholeConfig({ omit, only }: { omit?:string[], only?:string[]
111
// pass a value to `save` to force saving decision, or leave undefined for auto. Passing false will also reset previously loaded configs.
112
export function setConfig(newCfg: Record<string,unknown>, save?: boolean) {
113
const version = _.isString(newCfg.version) ? new Version(newCfg.version) : undefined
114
+ const considerEnvs = !process.env['HFS_ENV_BOOTSTRAP'] || !started && _.isEmpty(newCfg)
115
// first time we consider also CLI args
116
const argCfg = !started && _.pickBy(newObj(configProps,
116
- (x, k) => argv[k] ?? tryJson(process.env['HFS_' + k.toUpperCase()], _.identity)),
117
+ (x, k) => argv[k] ?? tryJson(considerEnvs ? process.env['HFS_' + k.toUpperCase()] : '', _.identity)),
118
x => x !== undefined)
119
if (! _.isEmpty(argCfg)) {
120
saveConfigAsap() // don't set `save` argument, as it would interfere below at check `save===false`