Code Monkey home page Code Monkey logo

morpheus's Introduction

Morpheus

Build Status codecov.io pypi

MIT license, Copyright (c) 2017 TutorCruncher & Samuel Colvin. See LICENSE for details.

"The Greek God of Dreams who delivered messages from the gods to the mortal world"

Okay, chill. We're not normally that astronomically arrogant. Just the obvious mythological name for a messaging platform - "hermes" was already taken by a plethora of terrible nineties mail clients.

What morpheus does:

  • sends emails and SMSs fast using mandrill, SES (TODO) and messagebird (SMS). One http request to send 5000 emails or SMSs.
  • generate PDFs for attachments given HTML using wkhtmltopdf.
  • provide a searchable history of sent messages and delivery analytics.
  • manage sending quotas as mandrill does when not using mandrill.

Here's a picture to help explain:

Morpheus and Iris

Usage

Running locally

Set up your environment

source activate.sh

then

docker build morpheus -t morpheus && docker-compose up -d

--build makes sure to build any changes to the morpheus image, -d is detach

At the same time in another window

until $(curl -so /dev/null http://localhost:8001/logs -I && true); do printf .; sleep 0.1; done && curl -s http://localhost:8001/logs

To view the logs

You can also run either the web or worker with

./morpheus/run.py web
# OR
./morpheus/run.py worker

You'll need elastic search and redis installed.

To prepare for deploy

Get ssl cert.pem and key.pem and put them in ./nginx/prod/keys, generate a password file for endpoints requiring basic auth.

sudo apt install apache2-utils
sudo htpasswd -c nginx/prod/pword <username>

Create activate.prod.sh:

#!/usr/bin/env bash
. env/bin/activate
export SCALEWAY_ORGANIZATION='...1'
export SCALEWAY_TOKEN='...'
export LOGSPOUT_ENDPOINT='...'
export RAVEN_DSN='...'
export APP_AUTH_KEY='...'
export APP_MANDRILL_KEY='...'
export APP_USER_AUTH_KEY='...'
export APP_HOST_NAME='...'
export APP_PUBLIC_LOCAL_API_URL='...'
export APP_ADMIN_BASIC_AUTH_PASSWORD='...'
export APP_S3_ACCESS_KEY='...'
export APP_S3_SECRET_KEY='...'

export APP_MESSAGEBIRD_KEY='...'
export APP_MESSAGEBIRD_PRICING_USERNAME='...'
export APP_MESSAGEBIRD_PRICING_PASSWORD='...'

echo "enabling docker machine..."
eval $(docker-machine env morpheus)

export MODE='PRODUCTION'
export PS1="PROD $PS1"

Setting up the machine

you'll need to add

vm.max_map_count=262144

To the end of /etc/sysctl.conf to allow elastic search to boot.

To deploy

Set up your environment

./start-prod.sh

(this assumes you have a prod gnome profile setup to differentiate commands going to the production server)

then

./deploy/deploy

That same command should also work to update the deployment after a change.

To test

Set up your environment. If you have ElasticSearch installed and running you're fine, or you can run it with:

./run-es.sh

then

make

to monitor

backup in progress (the pydf image has curl installed)

docker exec -it morpheus_pdf_1 curl elastic:9200/_cat/recovery?v

indices

docker exec -it morpheus_pdf_1 curl elastic:9200/_cat/indices/?v

to backup redis

docker exec -it morpheus_redis_1 redis-cli SAVE
docker cp morpheus_redis_1:/data/dump.rdb dump.rdb

to restore redis

./deploy/compose stop redis
docker cp dump.rdb morpheus_redis_1:/data/dump.rdb
./deploy/compose start redis

check with

docker exec -it morpheus_redis_1 redis-cli DBSIZE
docker exec -it morpheus_redis_1 redis-cli INFO

morpheus's People

Contributors

samuelcolvin avatar pyup-bot avatar tomhamiltonstubber avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.