Skip to content

Commit

Permalink
Update startup behaviour to run initial sync if db is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Aug 14, 2015
1 parent f07ba54 commit d807aae
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var express = require('express'),
cronJob = require('cron').CronJob,
winston = require('winston'),
rdb = require('./lib/redis'),
app = express(),
// search = require('./lib/search'),
packages = require('./lib/packages'),
Expand All @@ -16,4 +17,12 @@ winston.info('NodeBB Package Manager - Initializing');
new cronJob('0 * * * *', packages.registry.sync, null, true);

app.listen(process.env.PORT || 3000);
console.log('NodeBB Package Manager - Ready');
winston.info('NodeBB Package Manager - Ready');

// Check packaged sorted set. If missing, conduct initial sync
rdb.zcard('packages', function(err, numPackages) {
if (numPackages === 0) {
winston.info('No packages detected in database, running initial sync');
packages.registry.sync(true);
}
});

0 comments on commit d807aae

Please sign in to comment.