add settings and tweak url handling
This commit is contained in:
Родитель
9708c7fff6
Коммит
703407325c
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible Node.js debug attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"program": "${workspaceRoot}\\bin\\cc.js",
|
||||
"cwd": "${workspaceRoot}"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to Process",
|
||||
"port": 5858
|
||||
},
|
||||
{
|
||||
"name": "cc",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/bin/cc",
|
||||
"stopOnEntry": false,
|
||||
"args": [
|
||||
"-i"
|
||||
],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"preLaunchTask": null,
|
||||
"runtimeExecutable": null,
|
||||
"runtimeArgs": [
|
||||
"--nolazy"
|
||||
],
|
||||
"env": {
|
||||
"NODE_ENV": "localhost"
|
||||
},
|
||||
"console": "externalTerminal",
|
||||
"sourceMaps": false,
|
||||
"outFiles": []
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"jshint.options": {
|
||||
"esnext": true
|
||||
},
|
||||
"editor.folding": false,
|
||||
"editor.tabSize": 2,
|
||||
"editor.detectIndentation": false,
|
||||
"editor.formatOnType": true,
|
||||
"editor.insertSpaces": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
# Crawler command line
|
||||
|
||||
[GHCrawler](https://github.com/Microsoft/ospo-ghcrawler.git) is utility for walking GitHub APIs and tracking GitHub events. This command line app allows you to control various
|
||||
aspects of a crawler's behavior. There is some overlap in function with the [Crawler Dashboard](https://github.com/Microsoft/crawler-dashboard.git)
|
||||
|
||||
This project also has a simple Node client library for talking to a crawler.
|
||||
aspects of a crawler's behavior. There is some overlap in function with the [Crawler Dashboard](https://github.com/Microsoft/crawler-dashboard.git). This project also has a simple Node client library for talking to a crawler.
|
||||
|
||||
# Controlling a crawler
|
||||
|
||||
|
|
4
bin/cc
4
bin/cc
|
@ -27,7 +27,7 @@ function getCommands() {
|
|||
commands
|
||||
.version('0.0.1')
|
||||
.option('-i, --interactive', 'Run in interactive mode. Otherwise the given command is executed and this tool exits.')
|
||||
.option('-s, --service <url>', 'URL of the crawler service', url => crawlerUrl = url)
|
||||
.option('-s, --service <url>', 'URL of the crawler service', url => crawlerClient.url = url)
|
||||
.option('-t, --token <token>', 'Token for talking to the crawler service', token => authToken = token);
|
||||
commands
|
||||
.command('help')
|
||||
|
@ -70,7 +70,7 @@ function startReplLoop(commands) {
|
|||
output: process.stdout
|
||||
});
|
||||
|
||||
rl.setPrompt(crawlerUrl + '> ');
|
||||
rl.setPrompt(crawlerClient.url + '> ');
|
||||
rl.prompt();
|
||||
|
||||
rl.on('line', (line) => {
|
||||
|
|
|
@ -7,7 +7,7 @@ const Q = require('q');
|
|||
class CrawlerClient {
|
||||
|
||||
constructor(url, token) {
|
||||
this.crawlerUrl = process.env.CRAWLER_SERVICE_URL || 'http://localhost:3000';
|
||||
this.url = process.env.CRAWLER_SERVICE_URL || 'http://localhost:3000';
|
||||
this.authToken = process.env.CRAWLER_SERVICE_AUTH_TOKEN || 'secret';
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ class CrawlerClient {
|
|||
|
||||
configureCrawler(patch) {
|
||||
const deferred = Q.defer();
|
||||
request.patch(`${this.crawlerUrl}/config`, {
|
||||
request.patch(`${this.url}/config`, {
|
||||
headers: {
|
||||
'X-token': this.authToken
|
||||
},
|
||||
|
@ -48,7 +48,7 @@ class CrawlerClient {
|
|||
|
||||
getConfiguration() {
|
||||
const deferred = Q.defer();
|
||||
request.get(`${this.crawlerUrl}/config`, {
|
||||
request.get(`${this.url}/config`, {
|
||||
headers: {
|
||||
'X-token': this.authToken
|
||||
},
|
||||
|
@ -67,7 +67,7 @@ class CrawlerClient {
|
|||
|
||||
setTokens(tokens) {
|
||||
const deferred = Q.defer();
|
||||
request.put(`${this.crawlerUrl}/tokens`, {
|
||||
request.put(`${this.url}/tokens`, {
|
||||
headers: {
|
||||
'X-token': this.authToken
|
||||
},
|
||||
|
@ -86,7 +86,7 @@ class CrawlerClient {
|
|||
|
||||
queueRequests(requests, queueName = 'normal') {
|
||||
const deferred = Q.defer();
|
||||
request.post(`${this.crawlerUrl}/requests/${queueName}`, {
|
||||
request.post(`${this.url}/requests/${queueName}`, {
|
||||
headers: {
|
||||
'X-token': this.authToken
|
||||
},
|
Загрузка…
Ссылка в новой задаче