Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: npm/npm-logbot
base: f978a5ae39
...
head fork: npm/npm-logbot
compare: a055a27bd9
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 20 additions and 4 deletions.
  1. +2 −1  .gitignore
  2. +13 −0 cron.sh
  3. +5 −3 upload.js
View
3  .gitignore
@@ -1,2 +1,3 @@
config.js
-log*
+logs/
+uploaded/
View
13 cron.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+# usage:
+# /usr/bin/bash cron.sh /home/node/.ssh/id_rsa_whatever
+# run once per day to upload the previous day's logs
+
+# exit on any errors
+set -e
+
+id=$1
+scp -i $id ubuntu@npm.m.ic.ht:hosting/servers/isaacs/db/log.1 .
+
+dir=$(dirname $0)
+node $dir/upload.js log.1
View
8 upload.js
@@ -11,6 +11,8 @@ if (config.auth) {
var file = process.argv[2]
if (!file) throw new Error('usage: node upload.js <logfile>')
+var WORKERS = +process.env.WORKERS || 48
+
var request = require('request')
var LogParse = require('couchdb-log-parse')
var fs = require('fs')
@@ -22,9 +24,9 @@ var downloads = {}
var k
var counts = []
-console.error('Parsing log file...');
+console.error('Parsing log file... ' + file);
var st = fs.createReadStream(file)
-if (file.match(/\.gz$/)) st = st.pipe(zlib.Unzip())
+if (file.match(/\.gz$/)) st = st.pipe(zlib.Gunzip())
st.pipe(parser)
.on('message', function (msg) {
@@ -62,7 +64,7 @@ function uploadCounts () {
console.error('uploading count data...')
var i = 0;
- for (var i = 0; i < 32; i ++) work(i)
+ for (var i = 0; i < WORKERS; i ++) work(i)
}
function work (id) {

No commit comments for this range

Something went wrong with that request. Please try again.