Skip to content
Snippets Groups Projects
Commit b20a8377 authored by Jure's avatar Jure
Browse files

fix: close server and stop job queues on server close

parent ba2cdf00
No related branches found
No related tags found
No related merge requests found
......@@ -13,4 +13,6 @@ module.exports.NotFoundError = require('./errors/NotFoundError')
module.exports.startServer = require('./start-server')
// Jobs queue
module.exports.jobs = require('./jobs')
module.exports.jobs = {
connectToJobQueue: require('./jobs').connectToJobQueue,
}
......@@ -29,10 +29,10 @@ const startServer = async (app = express()) => {
// Add GraphQL subscriptions
addSubscriptions(httpServer)
// Start job queue
// Manage job queue
const jobQueue = await startJobQueue()
httpServer.on('close', () => {
jobQueue.stop()
httpServer.on('close', async () => {
await jobQueue.stop()
})
server = httpServer
......
......@@ -29,12 +29,12 @@ describe('integrated job queue', () => {
await jobQueue.onComplete(queueName, job => {
try {
expect(job.data.response).toEqual({ thing: 'theOtherThing' })
done()
jobQueue.stop().then(() => done())
} catch (e) {
done.fail(e)
}
})
})
afterAll(async () => server.close())
afterAll(done => server.close(done))
})
......@@ -1544,17 +1544,7 @@ babel-plugin-check-es2015-constants@^6.22.0:
dependencies:
babel-runtime "^6.22.0"
 
babel-plugin-istanbul@^4.0.0, babel-plugin-istanbul@^4.1.6:
version "4.1.6"
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz#36c59b2192efce81c5b378321b74175add1c9a45"
integrity sha512-PWP9FQ1AhZhS01T/4qLSKoHGY/xvkZdVBGlKM/HuxxS3+sC66HhTNR7+MpbO/so/cz/wY94MeSWJuP1hXIPfwQ==
dependencies:
babel-plugin-syntax-object-rest-spread "^6.13.0"
find-up "^2.1.0"
istanbul-lib-instrument "^1.10.1"
test-exclude "^4.2.1"
"babel-plugin-istanbul@https://github.com/jure/babel-plugin-istanbul.git#temp_release":
babel-plugin-istanbul@^4.0.0, babel-plugin-istanbul@^4.1.6, "babel-plugin-istanbul@https://github.com/jure/babel-plugin-istanbul.git#temp_release":
version "5.0.1"
resolved "https://github.com/jure/babel-plugin-istanbul.git#6499a20719e41d4f5556a479cba44ce262daf300"
dependencies:
......@@ -14585,17 +14575,6 @@ tempfile@^1.1.1:
os-tmpdir "^1.0.0"
uuid "^2.0.1"
 
test-exclude@^4.2.1:
version "4.2.3"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.2.3.tgz#a9a5e64474e4398339245a0a769ad7c2f4a97c20"
integrity sha512-SYbXgY64PT+4GAL2ocI3HwPa4Q4TBKm0cwAVeKOt/Aoc0gSpNRjJX8w0pA1LMKZ3LBmd8pYBqApFNQLII9kavA==
dependencies:
arrify "^1.0.1"
micromatch "^2.3.11"
object-assign "^4.1.0"
read-pkg-up "^1.0.1"
require-main-filename "^1.0.1"
test-exclude@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.0.0.tgz#cdce7cece785e0e829cd5c2b27baf18bc583cfb7"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment