lucasmartins / mailcannon-outpost

Please refer to

Home Page:https://github.com/mailcannon/mailcannon-outpost

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MailCannon Outpost

Use this wrapper to deploy your MailCannon workers to the war.

This is a work in PROGRESS, use it at your own risk

Install

Refer to the main gem for more details.

Download (or Clone/Fork) this repo, modify env.sh to meet your own variables and run it:

  $ git clone git@github.com:lucasmartins/mailcannon-outpost.git
  $ cd mailcannon-outpost
  $ . ./env.sample.sh # this will create an env.sh file.
  $ vim env.sh
  $ . ./env.sh

You should be able to run the wrapper like this:

  $ be sidekiq -r ./runner.rb --config=config/sidekiq.yml -v

You can access a console with MailCannon environment loaded like this:

  $ irb -r ./runner.rb

or like this on Heroku:

  $ heroku run 'bundle exec irb -r ./runner.rb'

MailCannon Outpost will use your MONGOBD_URL, take a look at your config/mongoid.yml file.

Use

Create a MailCannon::Envelope:

envelope = MailCannon::Envelope.create(
  from: 'test@mailcannon.com',
  to: [{email: 'lucasmartins@railsnapraia.com', name: 'Lucas Martins'}],
  subject: 'Test',
  mail: MailCannon::Mail.new(text: 'you will see this when no HTML reader is available', html: 'this should be an HTML'))

Auto-scaling

MailCannon Outpost has support for Hirefire (if you don't know it yet I strongly recommend you to check it out), you can also use Outpost's endpoint to implement your own auto-scaling.

The endpoint will try to use - if available - the environment variable HIREFIRE_TOKEN, if that's not the case, it will fallback to development mode:

curl http://my-mailcannon.com/hirefire/my_awesome_hirefire_token/info

curl http://localhost:3000/hirefire/development/info

The 'info' endpoint will return a JSON with the following structure:

[{"name":"worker", "quantity":0}]

Where 0 is the count of how many jobs are running right now.

In the future, this structure might change to accomodate more types of jobs - so there will be more hashes inside the array, with other names so you can scale it separately.

Caveats

MongoDB isn't an ACID database, you should be aware of MongoDB fundamentals (read the docs!) to put any app into production.

So depending on your setup, you may want to use synced operations to write your Envelopes to the database:

envelope = MailCannon::Envelope.with(safe: {j: true}).create(...)

Also, depending on your load, you may want to increase the waiting_time variable in your config/mailcannon.yml file to match your fsync cycle.

Contribute

Just fork MailCannon Outpost, add your feature/fix+spec, and make a pull request.

NOTICE: The project is at embrionary stage, breaking changes will apply.

Support

This is an opensource project so don't expect premium support, but don't be shy, post any troubles you're having in the Issues page and we'll do what we can to help.

License

MailCannon is free software under the FreeBSD license.

About

Please refer to

https://github.com/mailcannon/mailcannon-outpost


Languages

Language:Ruby 80.7%Language:Shell 19.3%