Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logging to the root of npm registry, if needed #31

Merged
merged 1 commit into from
Feb 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ module.exports = Command.extend({
host: {
type: 'string',
default: 'localhost'
},
'log-root': {
type: 'string'
}
},

run: function (folder, blobStore, clone, port, host, name) {
run: function (folder, blobStore, clone, port, host, logRoot) {
blobStore = path.resolve(__dirname, '../../ibs.js')

mirror({
outputDir: '/npm-registry/',
blobStore: blobStore,
clone: clone,
port: port,
host: host
host: host,
logRootPath: logRoot
})
}
})
14 changes: 14 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const serveNPM = require('./serve-npm')
const debug = require('debug')
const log = debug('registry-mirror')
log.err = debug('registry-mirror:error')
const ipfsAPI = require('ipfs-api')
const fs = require('fs')

exports = module.exports = (config) => {
// Update our /npm-registry MerkleDAG Node if needed
Expand All @@ -19,6 +21,18 @@ exports = module.exports = (config) => {
// Clone the entire NPM (and keep cloning)
if (config.clone) {
cloneNpm(config)

if (config.logRootPath) {
var apiCtl = ipfsAPI('/ip4/127.0.0.1/tcp/5001')
var stream = fs.createWriteStream(config.logRootPath)
setInterval(() => {
console.log('DING DONG')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahaha as I said above, still refactoring the whole thing xD

apiCtl.files.stat('/npm-registry', function (err, res) {
if (err) { return log.err(err) }
stream.write(Date.now() + ' ' + res.Hash + '\n')
})
}, 10000)
}
}

return serveNPM(config)
Expand Down