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

Commit

Permalink
Update to Node v8.10.0 (latest LTS). Added a unit test for cache path…
Browse files Browse the repository at this point in the history
…s with/without a trailing slash
  • Loading branch information
stephen-palmer committed Mar 16, 2018
1 parent 22eed8f commit 997337d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v8.9.4
v8.10.0
22 changes: 0 additions & 22 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ program.description("Unity Cache Server")
.option('-l, --log-level <n>', 'Specify the level of log verbosity. Valid values are 0 (silent) through 5 (debug)', myParseInt, consts.DEFAULT_LOG_LEVEL)
.option('-w, --workers <n>', 'Number of worker threads to spawn', zeroOrMore, consts.DEFAULT_WORKERS)
.option('-m --mirror [host:port]', 'Mirror transactions to another cache server. Can be repeated for multiple mirrors', collect, [])
.option('-m, --monitor-parent-process <n>', 'Monitor a parent process and exit if it dies', myParseInt, 0)
.option('--dump-config', 'Write the active configuration to the console')
.option('--save-config [path]', 'Write the active configuration to the specified file and exit. Defaults to ./default.yml')
.option('--NODE_CONFIG_DIR=<path>', 'Specify the directory to search for config files. This is equivalent to setting the NODE_CONFIG_DIR environment variable. Without this option, the built-in configuration is used.');
Expand Down Expand Up @@ -73,27 +72,6 @@ if(program.saveConfig || program.dumpConfig) {
helpers.setLogLevel(program.logLevel);
helpers.setLogger(program.workers > 0 ? helpers.defaultClusterLogger : helpers.defaultLogger);

if (program.monitorParentProcess > 0) {
function monitor() {
function is_running(pid) {
try {
return process.kill(pid, 0)
}
catch (e) {
return e.code === 'EPERM'
}
}

if (!is_running(program.monitorParentProcess)) {
helpers.log(consts.LOG_INFO, "monitored parent process has died");
process.exit(1);
}
setTimeout(monitor, 1000);
}

monitor();
}

const errHandler = function () {
helpers.log(consts.LOG_ERR, "Unable to start Cache Server");
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Unity Cache Server",
"main": "lib/index.js",
"engines": {
"node": "^8.9.4"
"node": "^8.10.0"
},
"directories": {
"test": "test"
Expand Down
16 changes: 15 additions & 1 deletion test/cache_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,27 @@ describe("Cache: Base Class", () => {
assert.strictEqual(cache._cachePath, opts.cachePath);
});

it("should return a subdirectory path relative to the app root if cachePath is not an abosolute path", () => {
it("should return a subdirectory path relative to the app root if cachePath is not an absolute path", () => {
cache._optionOverrides = {
cachePath: "abc123"
};

assert.strictEqual(cache._cachePath, path.join(path.dirname(require.main.filename), "abc123"));
});

it("should handle a trailing slash in the cache path", () => {
let noTrailingSlash = "/dir/without/trailing/slash";
let withTrailingSlash = "/dir/without/trailing/slash/";

cache._optionOverrides = {
cachePath: noTrailingSlash
};

assert.strictEqual(cache._cachePath, noTrailingSlash);

cache._optionOverrides.cachePath = withTrailingSlash;
assert.strictEqual(cache._cachePath, withTrailingSlash);
});
});

describe("init", () => {
Expand Down

0 comments on commit 997337d

Please sign in to comment.