Package: mercury-py
mercury-pymercury-py(Mercury for Python) is a Python based microservice that allow to manage scheduled notifications'
sending.IntroductionThe project consists of aFlask-basedRESTful Web API, through which it is possible to manage the scheduling
of notifications.SQLitedatabase is used internally.MongoDBdatabase is used to store scheduled notifications.The dispatch of notifications is managed byCelery-basedsubmodules:ACelery Beatthat acts as an activator for theWorkers.ACelery Workerfor each category of notification, who takes care of managing the specific type of dispatch.RabbitMQmessage-broker is used for interprocess communications.Notifications CategoriesThe categories of notifications that can currently be sent are:Email.Categories will be implemented:SMS;Push notification -Firebase Cloud Messaging(FCM);Telegrammessage.Setup instructionsGetting itTo download mercury, either fork thisGitHubrepo or simply download it fromPyPIviapip:pip install mercury-pyInstall DependenciesMercury needs:MongoDB: get it from the official site (https://www.mongodb.com/) or from the official
repository of your Linux distro, for example, onDebian-likesystems:sudo apt install mongodbRabbitMQ: get it from the official site (https://www.rabbitmq.com/) or from the official
repository of your Linux distro, for example, onDebian-likesystems:sudo apt install rabbitmq-serverAfter that, to use Mercury, we need to create aRabbitMQuser, a virtual host and allow that user access to that virtual host:From terminal, type (substitute in appropriate values for [MYUSER] and [MYPASSWORD] below):sudo rabbitmqctl add_user [MYUSER] [MYPASSWORD]
sudo rabbitmqctl add_vhost mercury
sudo rabbitmqctl set_permissions -p mercury [MYUSER] ".*" ".*" ".*"See theRabbitMQAdmin Guidefor more information about access control
(http://www.rabbitmq.com/admin-guide.html#access-control).Setting upCopy and paste fileconfig-*.py, from folderconfigs, into foldermercury-instanceand modify it according to your needs.Configure the Secret KeySECRET_KEY should be changed to some random bytes in production.You can use the following command to output a random secret key:$ python -c 'import os; print(os.urandom(16))'Then place returned value into yourconfig.py.StartingCelery WorkerAlternativeSourceYou can also embed beat inside the worker by enabling the workers -B option, this is convenient if you’ll never run more than one worker node, but it’s not commonly used and for that reason isn’t recommended for production use:celery -A mercury.app.celery worker -B --logfile=instance\logs\celery.log --pidfile=instance\celerybeat\celery.pid --schedule=instance\celerybeat\celery-schedule.db --loglevel=DEBUGNote:WindowsSystemsOnWindowssystems, an additional dependency must be installed in order for Celery-based submodules to function
properly.Download and installGeventfromPyPIviapip:pip install geventAnd run (Celery BeatandCelery Workers) from terminal:celery -A mercury.app.celery worker --logfile=instance/logs/celeryworker.log --loglevel=DEBUG --pool=gevent
celery -A mercury.app.celery beat --logfile=instance/logs/celerybeat.log --loglevel=DEBUG --pidfile=instance/celerybeat/celerybeat.pid --schedule=instance/celerybeat/celerybeat-schedule.db