When you want to track your exception and log messages in a UI rather than storing it in a file(which we usually do), we can use SENTRY. Sentry provides real-time crash reporting and exception tracking for your web and mobile apps.
In this Tutorial we will look on how to set up Sentry on a ubuntu VPS.
sudo apt-get update && sudo apt-get upgrade
apt-get install python-dev python-pip libpq-dev python-virtualenv libxml2-dev libxslt1-dev postgresql-9.3 libffi-dev libssh-dev nginx supervisor
cd <installation source directory> virtualenv env source env/bin/activate pip install sentry
Create sentry config files
sentry init <installation source directory>
Change Postgresql settings
sudo su postgres psql ALTER USER postgres PASSWORD 'mynewpassword'; \q # to exit createdb -E utf-8 sentry (as user postgres) Based on whether you want to use it as postgres user or any other user change one of the below setting to md5 local all postgres peer local all all peer
Newer versions of sentry need Redis > 2.8.9, visitthis link for more details on the ppas added below.
add-apt-repository ppa:chris-lea/redis-server apt-get install redis-server
Modify <installation source directory>/sentry.conf.py
SENTRY_WEB_OPTIONS = { 'workers': 5, # the number of web workers 'protocol': 'uwsgi', # Enable uwsgi protocol instead of http } Note: accordingly change postgresql, smtp and redis settings in config file.
SENTRY_CONF=<installation source directory> sentry upgrade You will be asked to create a superuser in between migration, which will be used to login into Sentry. In case if that doesnt happen use SENTRY_CONF=<installation source directory> sentry createuser
Add following lines to /etc/nginx/sites-enabled/sentry
server {
listen 80 <your ip address/domain>;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9000;
}
}
sudo service nginx restart
If we visit the domain or IP set you will receive a 502 Page, because the sentry application is not yet up and running, Lets Daemonize sentry through a supervisor.
Add Below Lines to /etc/supervisor/conf.d/sentry.conf
[program:sentry-web] command=/bin/bash -c "SENTRY_CONF=<installation source directory> <installation source directory>/env/bin/sentry run web" # format of command should be SENTRY_CONF=/home /home/env/bin/sentry run web autostart=true autorestart=true redirect_stderr=true stdout_logfile=/var/log/supervisor/sentry-out.log stderr_logfile=/var/log/supervisor/sentry-err.log [program:sentry-worker] command= /bin/bash -c "SENTRY_CONF=<installation source directory> <installation source directory>/env/bin/sentry celery worker" # format of command should be SENTRY_CONF=/home /home/env/bin/sentry celery worker environment=C_FORCE_ROOT="true" autostart=true autorestart=true redirect_stderr=true stdout_logfile=/var/log/supervisor/sentry-celery-out.log stderr_logfile=/var/log/supervisor/sentry-celery-err.log [program:sentry-beat] command= /bin/bash -c "SENTRY_CONF=/home /home/env/bin/sentry celery beat" environment=C_FORCE_ROOT="true" autostart=true autorestart=true redirect_stderr=true stdout_logfile=/var/log/supervisor/sentry-beat-out.log stderr_logfile=/var/log/supervisor/sentry-beat-err.log then execute these commands in shell to update the configurational changes. supervisorctl reread supervisorctl update
Now visit your domain and Login with Credentials you created during database migration
set domain as http://<yourdomain> (without trailing slash) and SMTP Details if any and start exploring sentry.
Visit this tutorial to learn how to create a project, team and track a Django Application.
Micropyramid is a software development and cloud consulting partner for enterprise businesses across the world. We work on python, Django, Salesforce, Angular, Reactjs, React Native, MySQL, PostgreSQL, Docker, Linux, Ansible, git, amazon web services. We are Amazon and salesforce consulting partner with 5 years of cloud architect experience. We develop e-commerce, retail, banking, machine learning, CMS, CRM web and mobile applications.
Django-CRM :Customer relationship management based on Django
Django-blog-it : django blog with complete customization and ready to use with one click installer Edit
Django-webpacker : A django compressor tool
Django-MFA : Multi Factor Authentication
Docker-box : Web Interface to manage full blown docker containers and images
More...