Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 44f2090

Browse files
committed
Read all relevant options from config file too
1 parent 5c662b8 commit 44f2090

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

config/default.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Cache:
22
defaultModule: "cache_fs"
3+
#port: 8126
4+
#workers: 2
5+
#log-level: 3
36
options:
47
cache_ram:
58
cachePath: ".cache_ram"

main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ function collect(val, memo) {
2727
}
2828

2929
const defaultCacheModule = config.get("Cache.defaultModule");
30+
const defaultCachePort = config.has('Cache.port') ? config.get('Cache.port') : consts.DEFAULT_PORT;
31+
const defaultLogLevel = config.has('Cache.log-level') ? config.get('Cache.log-level') : consts.DEFAULT_LOG_LEVEL;
32+
const defaultWorkers = config.has('Cache.workers') ? config.get('Cache.workers') : consts.DEFAULT_WORKERS
3033

3134
program.description("Unity Cache Server")
3235
.version(VERSION)
3336
.allowUnknownOption(true)
34-
.option('-p, --port <n>', 'Specify the server port, only apply to new cache server', myParseInt, consts.DEFAULT_PORT)
37+
.option('-p, --port <n>', 'Specify the server port, only apply to new cache server', myParseInt, defaultCachePort)
3538
.option('-c --cache-module [path]', 'Use cache module at specified path', defaultCacheModule)
3639
.option('-P, --cache-path [path]', 'Specify the path of the cache directory')
37-
.option('-l, --log-level <n>', 'Specify the level of log verbosity. Valid values are 0 (silent) through 5 (debug)', myParseInt, consts.DEFAULT_LOG_LEVEL)
38-
.option('-w, --workers <n>', 'Number of worker threads to spawn', zeroOrMore, consts.DEFAULT_WORKERS)
40+
.option('-l, --log-level <n>', 'Specify the level of log verbosity. Valid values are 0 (silent) through 5 (debug)', myParseInt, defaultLogLevel)
41+
.option('-w, --workers <n>', 'Number of worker threads to spawn', zeroOrMore, defaultWorkers)
3942
.option('-m --mirror [host:port]', 'Mirror transactions to another cache server. Can be repeated for multiple mirrors', collect, [])
4043
.option('--dump-config', 'Write the active configuration to the console')
4144
.option('--save-config [path]', 'Write the active configuration to the specified file and exit. Defaults to ./default.yml')

0 commit comments

Comments
 (0)