Mailspring/sync/app.js

35 lines
930 B
JavaScript
Raw Normal View History

2016-06-19 18:02:32 +08:00
const path = require('path');
global.__base = path.join(__dirname, '..')
global.config = require(`${__base}/core/config/${process.env.ENV || 'development'}.json`);
2016-06-20 15:19:16 +08:00
global.Promise = require('bluebird');
2016-06-19 18:02:32 +08:00
const DatabaseConnectionFactory = require(`${__base}/core/database-connection-factory`)
const SyncWorkerPool = require('./sync-worker-pool');
const workerPool = new SyncWorkerPool();
2016-06-21 08:28:26 +08:00
const RedisServer = require('redis-server');
const redisServerInstance = new RedisServer(6379);
const start = () => {
DatabaseConnectionFactory.setup()
DatabaseConnectionFactory.forShared().then((db) => {
const {Account} = db
Account.findAll().then((accounts) => {
accounts.forEach((account) => {
workerPool.addWorkerForAccount(account);
});
2016-06-19 18:02:32 +08:00
});
});
2016-06-21 08:28:26 +08:00
}
redisServerInstance.open((error) => {
if (error) {
console.error(error)
process.exit(1);
}
start()
2016-06-19 18:02:32 +08:00
});
global.workerPool = workerPool;