Skip to content

Commit

Permalink
Set the process to monitor updates for Hive
Browse files Browse the repository at this point in the history
  • Loading branch information
rjcorwin committed Mar 24, 2014
1 parent 24ad92d commit e113c39
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
1 change: 0 additions & 1 deletion data/history.orig.json

This file was deleted.

6 changes: 0 additions & 6 deletions data/updates.orig.json

This file was deleted.

13 changes: 13 additions & 0 deletions lib/TellHiveAboutUpdates.js
@@ -0,0 +1,13 @@
var Settings = require('../Settings')
var nano = require('nano')(Settings.CouchDB.URL)
var configDb = nano.use('config')

module.exports = function(updates, callback) {
configDb.get('HiveUpdates', function(err, doc) {
if (!doc) doc = {}
doc.updates = updates
configDb.insert(doc, 'HiveUpdates', function(err, res) {
callback(err, res)
})
})
}
24 changes: 23 additions & 1 deletion server.js
Expand Up @@ -5,7 +5,8 @@ var Backbone = require('backbone')
var _ = require('underscore')
var express = require('express')
var server = express()

var findUpdatesToRun = require('./lib/FindUpdatesToRun.js')
var tellHiveAboutUpdates = require('./lib/TellHiveAboutUpdates.js')

server.get('/*', function(req, res){

Expand Down Expand Up @@ -115,3 +116,24 @@ setTimeout(function() {
})

}, 30000)


/*
* Monitor available updates to let Hive know when they are available.
*/

var process = function() {
log('process', 'Telling Hive about updates.')
findUpdatesToRun(function(err, updates) {
if (err) return log('FindUpdatesToRun', err)
tellHiveAboutUpdates(updates, function(err, response) {
if (err) return log('TellHiveAboutUpdates', err)
return log('process', 'Finished telling hive about updates.')
})
})
}

setTimeout(function() {
process()
}, 5*60*1000)
process()
2 changes: 1 addition & 1 deletion util/Settings.default.js
@@ -1,3 +1,3 @@
module.exports = {
"path": "/root/.Hive-Updater"
"CouchDB": { "URL": "http://admin:password@127.0.0.1:5984" }
}

1 comment on commit e113c39

@rjcorwin
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lthiery Note the change to util/Settings.default.js in this commit.

Please sign in to comment.