diff --git a/README.md b/README.md index 6146bd6e..dd683a16 100644 --- a/README.md +++ b/README.md @@ -623,6 +623,14 @@ However, if you are trying to run Cronicle in an environment where WebSockets ar However, please only do this if you know exactly what you are doing, and why. +### max_jobs + +You can optionally set a global maximum number of concurrent jobs to allow. This is across all servers and categories, and is designed as an "emergency brake" for runaway events. The property is called `max_jobs`. The default is `0` (no limit). Example: + +```js +"max_jobs": 256 +``` + ## Storage Configuration The `Storage` object contains settings for the Cronicle storage system. This is built on the [pixl-server-storage](https://www.npmjs.com/package/pixl-server-storage) module, which can write everything to local disk (the default), [Couchbase](http://www.couchbase.com/nosql-databases/couchbase-server) or [Amazon S3](https://aws.amazon.com/s3/). diff --git a/lib/job.js b/lib/job.js index 4c823952..161d0ec1 100644 --- a/lib/job.js +++ b/lib/job.js @@ -131,6 +131,11 @@ module.exports = Class.create({ } } + var max_jobs = self.server.config.get('max_jobs') || 0; + if (max_jobs && (job_list.length >= max_jobs)) { + return callback( new Error("Global maximum of " + max_jobs + " " + Tools.pluralize("job", max_jobs) + " already running.") ); + } + if (!category.enabled) { return callback( new Error("Category '" + category.title + "' is disabled.") ); } diff --git a/package.json b/package.json index 3ea1b0dd..5b6ae138 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Cronicle", - "version": "0.8.60", + "version": "0.8.61", "description": "A simple, distributed task scheduler and runner with a web based UI.", "author": "Joseph Huckaby ", "homepage": "https://github.com/jhuckaby/Cronicle", diff --git a/sample_conf/config.json b/sample_conf/config.json index 09312f69..0af18d1e 100644 --- a/sample_conf/config.json +++ b/sample_conf/config.json @@ -25,6 +25,7 @@ "scheduler_startup_grace": 10, "universal_web_hook": "", "track_manual_jobs": false, + "max_jobs": 0, "server_comm_use_hostnames": false, "web_direct_connect": false,