-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1130 from AletheiaFact/service-runner-removal
Remove service-runner dependency and refactor code accordingly.
- Loading branch information
Showing
94 changed files
with
147 additions
and
996 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-2.93 KB
.yarn/cache/is-fullwidth-code-point-npm-1.0.0-0e436ba1ef-4d46a7465a.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-32.5 KB
.yarn/cache/npm-normalize-package-bin-npm-1.0.1-2cf38a5d95-ae7f15155a.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-2.94 KB
.yarn/cache/require-main-filename-npm-2.0.0-03eef65c84-e9e294695f.zip
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-8.28 KB
.yarn/cache/safe-json-stringify-npm-1.2.0-77cfd16d74-5bb32db6d6.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,4 @@ | ||
# Number of worker processes to spawn. | ||
# Use 'ncpu' to run as many workers as there are CPU units | ||
num_workers: 0 | ||
|
||
# Log error messages and gracefully restart a worker if v8 reports that it | ||
# uses more heap (note: not RSS) than this many mb. | ||
# worker_heap_limit_mb: 250 | ||
|
||
# Logger info | ||
logging: | ||
level: trace | ||
streams: | ||
- type: stdout # log to stdout | ||
named_levels: true # emit log level name instead of index. e.g. INFO vs 30 | ||
|
||
# Using config.yaml with wikimedia service-runner pattern | ||
services: | ||
- name: websocket-aletheia-development | ||
# path relative to the __dirname variable | ||
module: dist/server/websocket.js | ||
conf: | ||
port: 5051 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,4 @@ | ||
# Number of worker processes to spawn. | ||
# Use 'ncpu' to run as many workers as there are CPU units | ||
num_workers: 0 | ||
|
||
# Log error messages and gracefully restart a worker if v8 reports that it | ||
# uses more heap (note: not RSS) than this many mb. | ||
# worker_heap_limit_mb: 250 | ||
|
||
# Logger info | ||
logging: | ||
level: trace | ||
streams: | ||
- type: stdout # log to stdout | ||
named_levels: true # emit log level name instead of index. e.g. INFO vs 30 | ||
|
||
# Using config.yaml with wikimedia service-runner pattern | ||
services: | ||
- name: websocket-aletheia-development | ||
# path relative to the __dirname variable | ||
module: dist/server/websocket.js | ||
conf: | ||
port: 5051 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,10 @@ | |
"main": "./dist/server/main.js", | ||
"scripts": { | ||
"prepare": "husky install", | ||
"start": "service-runner", | ||
"start": "node dist/server/main.js", | ||
"copy-html-files": "copyfiles -u 1 server/**/*.html dist/server/", | ||
"seed": "yarn build-ts && yarn build-nest && yarn copy-html-files && node dist/server/command.js -c config.seed.yaml", | ||
"seed:ci": "yarn build-ts && yarn build-nest && yarn copy-html-files && node dist/server/command.js -c config.seed.test.ci.yaml", | ||
"seed": "yarn build-ts && yarn build-nest && yarn copy-html-files && node dist/server/seed.js -c config.seed.yaml", | ||
"seed:ci": "yarn build-ts && yarn build-nest && yarn copy-html-files && node dist/server/seed.js -c config.seed.test.ci.yaml", | ||
"dev": "yarn copy-static-assets && concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"cyan.bold,green.bold\" \"yarn watch-ts\" \"yarn watch-node\"", | ||
"test": "env-cmd --silent jest --detectOpenHandles --forceExit", | ||
"build": "yarn build-ts && yarn build-nest && yarn copy-static-assets && yarn copy-html-files && yarn build-next", | ||
|
@@ -23,8 +23,8 @@ | |
"lint:fix": "tsc --noEmit && eslint \"**/*.{js,ts,tsx}\" --quiet --fix", | ||
"copy-static-assets": "ts-node scripts/copyStaticAssets.ts", | ||
"watch-debug": "yarn copy-static-assets && concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"cyan.bold,green.bold\" \"yarn watch-ts\" \"yarn serve-debug\"", | ||
"watch-node": "nodemon dist/server/server.js --signal SIGTERM", | ||
"serve-debug": "nodemon --inspect dist/server/server.js --signal SIGTERM", | ||
"watch-node": "nodemon dist/server/main.js --signal SIGTERM", | ||
"serve-debug": "nodemon --inspect dist/server/main.js --signal SIGTERM", | ||
"clean": "rimraf **/{node_modules,dist}", | ||
"compodoc": "npx compodoc -p tsconfig.json -s -d ./docs/compodoc", | ||
"proxy": "ory proxy --no-jwt --port 4000 http://localhost:3000/", | ||
|
@@ -149,7 +149,6 @@ | |
"rehype-raw": "^6.1.1", | ||
"remirror": "^2.0.11", | ||
"rxjs": "^7.3.0", | ||
"service-runner": "^2.8.4", | ||
"set-cookie-parser": "^2.4.8", | ||
"sitemap": "5", | ||
"slugify": "^1.6.1", | ||
|
@@ -246,5 +245,8 @@ | |
"eslint --fix" | ||
] | ||
}, | ||
"resolutions": { | ||
"@types/mime": "3.0.4" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const fs = require("fs"); | ||
const yaml = require("js-yaml"); | ||
|
||
// Function extracted from service-runner codebase | ||
function _replaceEnvVars(config) { | ||
const envRegex = /{\s*env\(([^,\s)]+),?\s*([^)]+)?\)\s*}/g; | ||
if (Buffer.isBuffer(config)) { | ||
config = config.toString(); | ||
} | ||
return config.replace(envRegex, (match, envName, defValue) => { | ||
if (process.env[envName] !== undefined) { | ||
return process.env[envName]; | ||
} | ||
if (defValue !== undefined) { | ||
return defValue; | ||
} | ||
return ""; | ||
}); | ||
} | ||
function loadConfig() { | ||
const defaultConfigFilePath = "config.yaml"; | ||
const configFileIndex = process.argv.findIndex((arg) => arg === "-c"); | ||
const configFilePath = | ||
configFileIndex !== -1 ? process.argv[configFileIndex + 1] : null; | ||
|
||
let configContent = fs.readFileSync( | ||
configFilePath || defaultConfigFilePath, | ||
"utf8" | ||
); | ||
configContent = _replaceEnvVars(configContent); | ||
|
||
const doc = yaml.load(configContent); | ||
const { conf: options } = doc.services[0]; | ||
|
||
return options; | ||
} | ||
|
||
export default loadConfig; |
Oops, something went wrong.