mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-28 18:14:08 +08:00
Add Procfile and heroku readiness
This commit is contained in:
parent
9dad99801c
commit
7602620742
6 changed files with 38 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
storage/a-1.sqlite
|
storage/a-1.sqlite
|
||||||
|
.env
|
||||||
|
|
2
Procfile
Normal file
2
Procfile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
web: node api/app.js
|
||||||
|
worker: node sync/app.js
|
|
@ -12,17 +12,17 @@ module.exports = (server) => {
|
||||||
handler: (request, reply) => {
|
handler: (request, reply) => {
|
||||||
const outputStream = require('stream').Readable();
|
const outputStream = require('stream').Readable();
|
||||||
outputStream._read = () => { return };
|
outputStream._read = () => { return };
|
||||||
const pushMsg = (msg = "\n") => outputStream.push(msg);
|
const sendMsg = (msg = "\n") => outputStream.push(msg);
|
||||||
|
|
||||||
request.getAccountDatabase()
|
request.getAccountDatabase()
|
||||||
.then((db) => {
|
.then((db) => {
|
||||||
return db.Transaction.findAll(findParams(request.query))
|
return db.Transaction.findAll(findParams(request.query))
|
||||||
.then((transactions = []) => {
|
.then((transactions = []) => {
|
||||||
transactions.map(JSON.stringify).forEach(pushMsg);
|
transactions.map(JSON.stringify).forEach(sendMsg);
|
||||||
DeltaStreamQueue.subscribe(db.accountId, pushMsg)
|
DeltaStreamQueue.subscribe(db.accountId, sendMsg)
|
||||||
})
|
})
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const keepAlive = setInterval(pushMsg, 1000);
|
const keepAlive = setInterval(sendMsg, 1000);
|
||||||
request.on("disconnect", () => { clearTimeout(keepAlive) })
|
request.on("disconnect", () => { clearTimeout(keepAlive) })
|
||||||
return reply(outputStream)
|
return reply(outputStream)
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,7 @@ bluebird.promisifyAll(redis.Multi.prototype);
|
||||||
|
|
||||||
class DeltaStreamQueue {
|
class DeltaStreamQueue {
|
||||||
setup() {
|
setup() {
|
||||||
this.client = redis.createClient();
|
this.client = redis.createClient(process.env.REDIS_URL);
|
||||||
this.client.on("error", console.error);
|
this.client.on("error", console.error);
|
||||||
this.client.on("ready", () => console.log("Redis ready"));
|
this.client.on("ready", () => console.log("Redis ready"));
|
||||||
}
|
}
|
||||||
|
|
30
package.json
Normal file
30
package.json
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "k2",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "Sync Engine ++",
|
||||||
|
"main": "",
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {},
|
||||||
|
"scripts": {
|
||||||
|
"start": "heroku local",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"imap-experiment": "./sync",
|
||||||
|
"api": "./api"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/nylas/K2.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/nylas/K2/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/nylas/K2#readme",
|
||||||
|
"engines": {
|
||||||
|
"node": "6.2.2",
|
||||||
|
"npm": "3.9.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,6 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "brew install redis",
|
|
||||||
"start": "node app.js",
|
"start": "node app.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue