From e03ee962167f60fa156f9cfc0941ae2c68f49167 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 7 Jan 2015 10:33:55 +0000 Subject: [PATCH] added simple clustering master --- services/filestore/Gruntfile.coffee | 4 ++-- services/filestore/cluster.coffee | 9 +++++++++ services/filestore/package.json | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 services/filestore/cluster.coffee diff --git a/services/filestore/Gruntfile.coffee b/services/filestore/Gruntfile.coffee index aa40cf7460..a506496578 100644 --- a/services/filestore/Gruntfile.coffee +++ b/services/filestore/Gruntfile.coffee @@ -14,7 +14,7 @@ module.exports = (grunt) -> app_server: expand: true, flatten: false, - src: ['app.coffee'], + src: ['app.coffee', 'cluster.coffee'], dest: './', ext: '.js' @@ -36,7 +36,7 @@ module.exports = (grunt) -> watch: server_coffee: - files: ['app/*.coffee','app/**/*.coffee', 'test/unit/coffee/**/*.coffee', 'test/unit/coffee/*.coffee', "app.coffee"] + files: ['app/*.coffee','app/**/*.coffee', 'test/unit/coffee/**/*.coffee', 'test/unit/coffee/*.coffee', "app.coffee", "cluster.coffee"] tasks: ["clean", 'coffee', 'mochaTest'] clean: ["app/js", "test/unit/js", "app.js"] diff --git a/services/filestore/cluster.coffee b/services/filestore/cluster.coffee new file mode 100644 index 0000000000..a0ca60a619 --- /dev/null +++ b/services/filestore/cluster.coffee @@ -0,0 +1,9 @@ +recluster = require "recluster" # https://github.com/doxout/recluster +path = require "path" + +cluster = recluster path.join(__dirname, 'app.js'), { + workers: 2, + backoff: 0, + readyWhen: "listening" +} +cluster.run() diff --git a/services/filestore/package.json b/services/filestore/package.json index be103715f7..3586041555 100644 --- a/services/filestore/package.json +++ b/services/filestore/package.json @@ -20,6 +20,7 @@ "node-transloadit": "0.0.4", "node-uuid": "~1.4.1", "pngcrush": "0.0.3", + "recluster": "^0.3.7", "request": "2.14.0", "settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#master", "stream-buffers": "~0.2.5",