diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-08-26 13:52:12 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-08-26 14:23:24 +0200 |
commit | 36393e1d2b1ce82916bd43ca1068e34cea6f6e39 (patch) | |
tree | a18d7f5e7753ff40355d2a6d4ab9fb765ad4c263 /streaming/index.js | |
parent | 2903f8f36b7c41b77de4ad6c8c5b0a6c0b2a7ace (diff) | |
parent | f37fafe30b5f6ff85ebf87fb622293a855877ee1 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: app/views/layouts/application.html.haml Edited: app/helpers/application_helper.rb app/views/admin/domain_blocks/new.html.haml Conflict wasn't really one, just two changes too close to one another. Edition was to adapt the class names for themes to class names for skins and flavours. Also edited app/views/admin/domain_blocks/new.html.haml to strip the duplicate admin pack inclusion thing.
Diffstat (limited to 'streaming/index.js')
-rw-r--r-- | streaming/index.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/streaming/index.js b/streaming/index.js index d7bfa6542..1c6004b77 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -9,6 +9,7 @@ const log = require('npmlog'); const url = require('url'); const WebSocket = require('uws'); const uuid = require('uuid'); +const fs = require('fs'); const env = process.env.NODE_ENV || 'development'; @@ -70,6 +71,9 @@ const redisUrlToClient = (defaultConfig, redisUrl) => { const numWorkers = +process.env.STREAMING_CLUSTER_NUM || (env === 'development' ? 1 : Math.max(os.cpus().length - 1, 1)); const startMaster = () => { + if (!process.env.SOCKET && process.env.PORT && isNaN(+process.env.PORT)) { + log.warn('UNIX domain socket is now supported by using SOCKET. Please migrate from PORT hack.'); + } log.info(`Starting streaming API server master with ${numWorkers} workers`); }; @@ -448,6 +452,12 @@ const startWorker = (workerId) => { app.use(setRequestId); app.use(setRemoteAddress); app.use(allowCrossDomain); + + app.get('/api/v1/streaming/health', (req, res) => { + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('OK'); + }); + app.use(authenticationMiddleware); app.use(errorMiddleware); @@ -574,9 +584,16 @@ const startWorker = (workerId) => { }); }, 30000); - server.listen(process.env.PORT || 4000, process.env.BIND || '0.0.0.0', () => { - log.info(`Worker ${workerId} now listening on ${server.address().address}:${server.address().port}`); - }); + if (process.env.SOCKET || process.env.PORT && isNaN(+process.env.PORT)) { + server.listen(process.env.SOCKET || process.env.PORT, () => { + fs.chmodSync(server.address(), 0o666); + log.info(`Worker ${workerId} now listening on ${server.address()}`); + }); + } else { + server.listen(+process.env.PORT || 4000, process.env.BIND || '0.0.0.0', () => { + log.info(`Worker ${workerId} now listening on ${server.address().address}:${server.address().port}`); + }); + } const onExit = () => { log.info(`Worker ${workerId} exiting, bye bye`); |