Comparing version 0.2.5 to 0.2.6
@@ -20,2 +20,3 @@ | ||
.option('-r, --recover','recover mode, read seed from database') | ||
.option('-i, --init','generate scaffold') | ||
.option('-n, --name<name>','app to run') | ||
@@ -22,0 +23,0 @@ .parse(process.argv); |
@@ -39,2 +39,3 @@ | ||
delegate(context.prototype, 'response') | ||
.method('get') | ||
.getter('status') | ||
@@ -58,3 +59,2 @@ .getter('message') | ||
// .method('accepts') | ||
.method('get') | ||
.method('is') | ||
@@ -61,0 +61,0 @@ .access('querystring') |
@@ -66,3 +66,6 @@ | ||
_back(ctx){ | ||
this._job.sendWorkData( JSON.stringify([...ctx.dataSet]) ); | ||
if(ctx.dataSet.size > 0){ | ||
this._job.sendWorkData( JSON.stringify([...ctx.dataSet]) ); | ||
} | ||
this._job.workComplete( JSON.stringify(ctx.tasks) ); | ||
@@ -102,2 +105,22 @@ } | ||
/* Hook process signal (current is INT) | ||
* which is sent by `Ctrl+c` | ||
* or `kill -SIGINT <pid>` | ||
* | ||
*/ | ||
_hookSIG(){ | ||
process.on('SIGINT',this._exit.bind(this)); | ||
} | ||
/* Exit gracefully | ||
* notify server that worker no longer receive job | ||
* and close connection | ||
* | ||
*/ | ||
_exit(){ | ||
this._w.resetAbilities(); | ||
this._w.close(); | ||
process.exit(0); | ||
} | ||
/* Initilize Gearman Worker, | ||
@@ -109,19 +132,9 @@ * register functions, initialize scheduler and subscribe events of `Core` | ||
_init(){ | ||
let w = gearman.worker(this.config.gearman);//register worker to master | ||
let appname = this.app.name; | ||
let self = this; | ||
this._w = gearman.worker(this.config.gearman)//register worker to master | ||
this.retryPriority = 10; | ||
this._hookSIG(); | ||
this.initializeScheduler(this.config.schedule); | ||
functionsIn(this.app).forEach( fnKey => w.addFunction(appname+"_"+fnKey, self._onJob(fnKey) ) );//bind functions | ||
process.on('SIGINT', function(){//ctrl+c | ||
functionsIn(this.app).forEach(function(fnKey){//bind functions | ||
w.removeFunction(appname+"_"+fnKey); | ||
}); | ||
w.close(); | ||
process.exit(0); | ||
}); | ||
this.initializeScheduler(this.config.schedule); | ||
functionsIn(this.app).forEach( fnKey => this._w.addFunction(this.app.name+"_"+fnKey, this._onJob(fnKey) ), this);//bind functions | ||
this.on("request", this._send.bind(this) ) | ||
@@ -128,0 +141,0 @@ .on("response", this._parse.bind(this) ) |
{ | ||
"name": "floodesh", | ||
"version": "0.2.5", | ||
"description": "Floodesh is a distributed web spider/crawler written with Nodejs.", | ||
"bin":"./bin/floodesh", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/bda-research/floodesh" | ||
}, | ||
"keywords": [ | ||
"nodejs", | ||
"distributed", | ||
"web", | ||
"spider", | ||
"crawler" | ||
], | ||
"author": "Mike Chen", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/bda-research/floodesh/issues" | ||
}, | ||
"homepage": "https://github.com/bda-research/floodesh", | ||
"dependencies": { | ||
"request":"^2.69.0", | ||
"bottleneckp": "^1.0.0", | ||
"delegates":"^1.0.0", | ||
"commander": "^2.9.0", | ||
"content-type": "^1.0.1", | ||
"gearman-node-bda": "^0.9.3", | ||
"lodash": "^4.0.1", | ||
"mof": "0.1.0", | ||
"mongodb": "^2.1.4", | ||
"statuses": "^1.2.1", | ||
"type-is": "^1.6.10", | ||
"winston": "^2.1.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.4.5", | ||
"mof-cheerio": "^1.0.1", | ||
"should": "^8.2.1" | ||
} | ||
"name": "floodesh", | ||
"version": "0.2.6", | ||
"description": "Floodesh is a distributed web spider/crawler written with Nodejs.", | ||
"bin": "./bin/floodesh", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "./node_modules/mocha/bin/mocha --reporter spec --bail --timeout 10000 tests/test-worker.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/bda-research/floodesh" | ||
}, | ||
"keywords": [ | ||
"nodejs", | ||
"distributed", | ||
"web", | ||
"spider", | ||
"crawler" | ||
], | ||
"author": "Mike Chen", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/bda-research/floodesh/issues" | ||
}, | ||
"homepage": "https://github.com/bda-research/floodesh", | ||
"dependencies": { | ||
"request": "^2.69.0", | ||
"bottleneckp": "^1.0.0", | ||
"delegates": "^1.0.0", | ||
"commander": "^2.9.0", | ||
"content-type": "^1.0.1", | ||
"gearman-node-bda": "^0.9.3", | ||
"lodash": "^4.0.1", | ||
"mof": "0.1.0", | ||
"mongodb": "^2.1.4", | ||
"statuses": "^1.2.1", | ||
"type-is": "^1.6.10", | ||
"winston": "^2.1.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.4.5", | ||
"mof-cheerio": "^1.0.1", | ||
"should": "^8.2.1", | ||
"should-sinon": "0.0.5", | ||
"sinon": "^1.17.3" | ||
} | ||
} |
@@ -5,2 +5,14 @@ # floodesh | ||
# Install | ||
$ npm install floodesh | ||
# Useage | ||
Before you use floodesh make sure you have [gearman](http://gearman.org/) server running on localhost | ||
$ mkdir floodesh_demo | ||
$ cd floodesh_demo | ||
$ floodesh --init | ||
First install Gearman | ||
@@ -15,2 +27,2 @@ ` | ||
You may first install `libboost-all-dev`, `gperf`, `libevent-dev`, `uuid-dev` | ||
You may first install `libboost-all-dev`, `gperf`, `libevent-dev`, `uuid-dev` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
41838
26
1513
1
27
5
1
1