mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Fix leakage of subprocesses
@mattwr18 and I could not find any other way how to prevent leftover processes than using a complex list of npm scripts. Watch: http://youtu.be/byovuFwNXiw and see how we despearately try to fix this stupid problem.
This commit is contained in:
parent
5dbe5b16a4
commit
c1395f7ec1
14
package.json
14
package.json
@ -9,12 +9,16 @@
|
||||
"scripts": {
|
||||
"build": "babel src/ -d dist/ --copy-files",
|
||||
"start": "node dist/",
|
||||
"dev": "nodemon --exec babel-node src/index.js",
|
||||
"dev": "nodemon --exec babel-node src/",
|
||||
"dev:debug": "nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js",
|
||||
"lint": "eslint src --config .eslintrc.js",
|
||||
"test": "nyc --reporter=text-lcov yarn run test:jest",
|
||||
"test:jest": "jest --forceExit --detectOpenHandles --runInBand",
|
||||
"test:jest:debug": "node --inspect-brk ./node_modules/.bin/jest -i --forceExit --detectOpenHandles --runInBand",
|
||||
"test:before:server": "cross-env GRAPHQL_URI=http://localhost:4123 GRAPHQL_PORT=4123 babel-node src/ 2> /dev/null",
|
||||
"test:before:seeder": "cross-env GRAPHQL_URI=http://localhost:4001 GRAPHQL_PORT=4001 PERMISSIONS=disabled babel-node src/ 2> /dev/null",
|
||||
"test:jest:cmd": "wait-on tcp:4001 tcp:4123 && jest --forceExit --detectOpenHandles --runInBand",
|
||||
"test:jest:cmd:debug": "wait-on tcp:4001 tcp:4123 && node --inspect-brk ./node_modules/.bin/jest -i --forceExit --detectOpenHandles --runInBand",
|
||||
"test:jest": "run-p --race test:before:* 'test:jest:cmd {@}' --",
|
||||
"test:jest:debug": "run-p --race test:before:* 'test:jest:cmd:debug {@}' --",
|
||||
"test:coverage": "nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"db:script:seed": "wait-on tcp:4001 && babel-node src/seed/seed-db.js",
|
||||
"db:script:reset": "wait-on tcp:4001 && babel-node src/seed/reset-db.js",
|
||||
@ -27,9 +31,7 @@
|
||||
"verbose": true,
|
||||
"testMatch": [
|
||||
"**/src/**/?(*.)+(spec|test).js?(x)"
|
||||
],
|
||||
"globalSetup": "<rootDir>/src/jest/globalSetup",
|
||||
"globalTeardown": "<rootDir>/src/jest/globalTeardown"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"apollo-cache-inmemory": "~1.3.12",
|
||||
|
||||
1
scripts/test.sh
Executable file
1
scripts/test.sh
Executable file
@ -0,0 +1 @@
|
||||
#!/usr/bin/env bash
|
||||
@ -1 +0,0 @@
|
||||
module.exports = require('./hooks').setup
|
||||
@ -1 +0,0 @@
|
||||
module.exports = require('./hooks').teardown
|
||||
@ -1,45 +0,0 @@
|
||||
const { spawn } = require('child_process')
|
||||
const waitOn = require('wait-on')
|
||||
|
||||
let server
|
||||
let seeder
|
||||
|
||||
const setup = async function () {
|
||||
server = spawn('babel-node', ['src/index'], {
|
||||
env: Object.assign({}, process.env, {
|
||||
GRAPHQL_URI: 'http://localhost:4123',
|
||||
GRAPHQL_PORT: '4123'
|
||||
})
|
||||
})
|
||||
|
||||
seeder = spawn('babel-node', ['src/index'], {
|
||||
env: Object.assign({}, process.env, {
|
||||
GRAPHQL_URI: 'http://localhost:4001',
|
||||
GRAPHQL_PORT: '4001',
|
||||
PERMISSIONS: 'disabled'
|
||||
})
|
||||
})
|
||||
|
||||
server.stdout.on('data', data => console.log(`server stdout:\n${data}`))
|
||||
server.stderr.on('data', data => console.log(`server stderr:\n${data}`))
|
||||
seeder.stdout.on('data', data => console.log(`seeder stdout:\n${data}`))
|
||||
seeder.stderr.on('data', data => console.log(`seeder stderr:\n${data}`))
|
||||
|
||||
try {
|
||||
await waitOn({
|
||||
resources: ['http://localhost:4123', 'http://localhost:4001']
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
|
||||
const teardown = async function () {
|
||||
server.kill()
|
||||
seeder.kill()
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setup,
|
||||
teardown
|
||||
}
|
||||
@ -28,7 +28,7 @@ export default {
|
||||
})
|
||||
removeIdFromResult = true
|
||||
}
|
||||
} catch(err) {}
|
||||
} catch (err) {}
|
||||
const result = await resolve(root, args, context, info)
|
||||
if (!isIdPresent && removeIdFromResult) {
|
||||
// remove id if the user did not ask for it
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user