You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.0 KiB
JavaScript
83 lines
2.0 KiB
JavaScript
var Eviction = require("../lib/eviction");
|
|
var nThen = require("nthen");
|
|
var Store = require("../lib/storage/file");
|
|
var BlobStore = require("../lib/storage/blob");
|
|
|
|
var Quota = require("../lib/commands/quota");
|
|
|
|
var Env = {
|
|
config: require("../lib/load-config"),
|
|
};
|
|
|
|
var prepareEnv = function (Env, cb) {
|
|
var config = Env.config;
|
|
|
|
Env.customLimits = config.customLimits;
|
|
Quota.applyCustomLimits(Env);
|
|
|
|
nThen(function (w) {
|
|
/* Database adaptors
|
|
*/
|
|
|
|
// load the store which will be used for iterating over channels
|
|
// and performing operations like archival and deletion
|
|
Store.create(config, w(function (err, _) {
|
|
if (err) {
|
|
w.abort();
|
|
throw err;
|
|
}
|
|
Env.store = _;
|
|
}));
|
|
|
|
Store.create({
|
|
filePath: config.pinPath,
|
|
}, w(function (err, _) {
|
|
if (err) {
|
|
w.abort();
|
|
throw err;
|
|
}
|
|
Env.pinStore = _;
|
|
}));
|
|
|
|
// load the logging module so that you have a record of which
|
|
// files were archived or deleted at what time
|
|
var Logger = require("../lib/log");
|
|
Logger.create(config, w(function (_) {
|
|
Env.Log = _;
|
|
}));
|
|
|
|
config.getSession = function () {};
|
|
BlobStore.create(config, w(function (err, _) {
|
|
if (err) {
|
|
w.abort();
|
|
return console.error(err);
|
|
}
|
|
Env.blobStore = _;
|
|
}));
|
|
}).nThen(function () {
|
|
cb();
|
|
});
|
|
};
|
|
|
|
var shutdown = function (Env) {
|
|
// the store will keep this script running if you don't shut it down
|
|
//Env.store.shutdown();
|
|
//Env.Log.shutdown();
|
|
//Env.pinStore.shutdown();
|
|
};
|
|
|
|
nThen(function (w) {
|
|
// load database adaptors and configuration values into the environment
|
|
prepareEnv(Env, w(function () {
|
|
|
|
|
|
}));
|
|
}).nThen(function (w) {
|
|
Eviction(Env, w(function () {
|
|
|
|
}));
|
|
}).nThen(function () {
|
|
// shut down database adaptors
|
|
shutdown(Env);
|
|
});
|