From ae32666609a75622dc8423a98e976b99e85a8405 Mon Sep 17 00:00:00 2001 From: Karim Hamidou Date: Thu, 2 Feb 2017 16:02:17 -0800 Subject: [PATCH] [cloud-api] Base infrastructure for running cloud workers Summary: I've decided to break my snooze patches in multiple parts to make it easier to review. This diff contains all the code related to running workers in the cloud. Cloud workers all inherit from the `Worker` class which defines a bunch of useful things like error handling. What's left to do: - spawn workers based on the plugin type - add monitoring (I'm going to add a simple HTTP endpoint for that) - writing a migration for the local sync db and the prod metadata db. Test Plan: Tested manually. Reviewers: halla, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3814 --- packages/local-sync/src/models/message.js | 1 + pm2-dev.yml | 5 +++-- scripts/run-redis.sh | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 scripts/run-redis.sh diff --git a/packages/local-sync/src/models/message.js b/packages/local-sync/src/models/message.js index c4286f3ba..e90fd113e 100644 --- a/packages/local-sync/src/models/message.js +++ b/packages/local-sync/src/models/message.js @@ -217,6 +217,7 @@ module.exports = (sequelize, Sequelize) => { labels: this.labels ? this.labels.map(l => l.toJSON()) : [], imap_uid: this.folderImapUID, thread_id: this.threadId, + message_id_header: this.headerMessageId, }; }, }, diff --git a/pm2-dev.yml b/pm2-dev.yml index 1975da95d..43c88302e 100644 --- a/pm2-dev.yml +++ b/pm2-dev.yml @@ -19,8 +19,9 @@ apps: watch : ["packages"] name : workers env : + DB_NAME : "nylasmailclouddb" DB_ENCRYPTION_ALGORITHM : "aes-256-ctr" DB_ENCRYPTION_PASSWORD : "d6F3Efeq" NODE_ENV: 'development' - - script : redis-server - name : redis + - script : scripts/run-redis.sh + name : redis diff --git a/scripts/run-redis.sh b/scripts/run-redis.sh new file mode 100755 index 000000000..ddac71cd1 --- /dev/null +++ b/scripts/run-redis.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Redis is one of those servers which by default +# accept connections from everywhere. Luckily, +# homebrew and presumably debian come with sane +# defaults. However, they're located in different +# directories. +if [[ $(uname) = 'Darwin' ]]; then + echo "Running redis from Homebrew..." + redis-server /usr/local/etc/redis.conf +fi + +if [[ $(uname) = 'Linux' ]]; then + echo "Running redis" + redis-server /etc/redis/redis.conf +fi