Skip to content

Instantly share code, notes, and snippets.

View shudarshon's full-sized avatar
🎯
Focusing

Shudarshon Chaki shudarshon

🎯
Focusing
View GitHub Profile
@shudarshon
shudarshon / install_grafana.sh
Created July 7, 2017 17:06
This script is used for provisioning Grafana docker image in Ubuntu 16.04/Debian machine. Grafana is used for metric data visualization and monitoring.
#!/bin/bash
apt-get update
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
apt-get update
apt-get install -y docker-engine
systemctl enable docker
usermod -aG docker ubuntu
docker info
curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)"
@shudarshon
shudarshon / nginx.conf
Created July 7, 2017 17:17
This is nginx configuration file consisting multiple SSL with reverse proxy & force https redirection implementation.
server {
listen 80;
listen 443 ssl;
server_name A.B.C.D app1-domain;
ssl_certificate /etc/letsencrypt/live/app1/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app1/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
@shudarshon
shudarshon / uwsgi.conf
Created July 7, 2017 17:24
This is a supervisor script for application server UWSGI which serves django applications.
[program:uwsgi]
command=/home/ubuntu/virtualenv/app/bin/uwsgi --http 0.0.0.0:8000 -b 65535 --chdir /home/ubuntu/app --wsgi-file /home/ubuntu/app/appdir/wsgi.py --virtualenv /home/ubuntu/virtualenv/app
user=ubuntu
numprocs=1
stdout_logfile=/var/log/uwsgi/access.log
stderr_logfile=/var/log/uwsgi/error.log
autostart=true
autorestart=true
@shudarshon
shudarshon / celerybeat.conf
Created July 7, 2017 17:29
This is a supervisor script which runs celerybeat in background.
[program:celerybeat]
command=/home/ubuntu/virtual-env/app/bin/python manage.py celery beat
directory=/home/ubuntu/app
environment=C_FORCE_ROOT=true
user=ubuntu
numprocs=1
stdout_logfile=/var/log/celerybeat/access.log
stderr_logfile=/var/log/celerybeat/error.log
autostart=true
@shudarshon
shudarshon / celeryd.conf
Created July 7, 2017 17:34
This is a supervisor script which runs celeryd in background.
[program:celeryd]
command=/home/ubuntu/virtual-env/app/bin/python manage.py celeryd -l INFO
directory=/home/ubuntu/app
environment=C_FORCE_ROOT=true
user=ubuntu
numprocs=1
stdout_logfile=/var/log/celeryd/access.log
stderr_logfile=/var/log/celeryd/error.log
autostart=true
@shudarshon
shudarshon / app_dcmqrscp.conf
Created July 7, 2017 17:37
This supervisor script runs dcmqrscp application in background for DICOM demonstration.
[program:dcmqrscp]
command=dcmqrscp --config /home/ubuntu/app/dcmqrscp.cfg
user=ubuntu
numprocs=1
stdout_logfile=/var/log/dcmqrscp/access.log
stderr_logfile=/var/log/dcmqrscp/error.log
autostart=true
autorestart=true
startsecs=10
@shudarshon
shudarshon / dcmtk_listener.conf
Created July 7, 2017 17:41
This is a supervisor script for running DCMTK listener application in background .
[program:dcmtk_listener]
command=storescp 5555 -aet app -xcs '. /home/ubuntu/virtual-env/app/bin/activate; cd /home/ubuntu/app/; python manage.py add_dicom #p' --log-config /home/ubuntu/app/dcmtk_log_config.txt -od /home/ubuntu/app/dicoms/ -su ah -tos 30 --accept-all -fe '.dcm'
environment=C_FORCE_ROOT=true
user=ubuntu
numprocs=1
stdout_logfile=/var/log/dcmtk_listener/access.log
stderr_logfile=/var/log/dcmtk_listener/error.log
autostart=true
@shudarshon
shudarshon / flower.conf
Created July 7, 2017 17:44
This is a supervisor script which runs flower program in background which is user for rabbitmq queue monitoring.
[program:flower]
command=/home/ubuntu/virtual-env/app/bin/flower --address=0.0.0.0 --port=5000 --basic_auth=USER:PASSWORD
user=ubuntu
numprocs=1
stdout_logfile=/var/log/flower/access.log
stderr_logfile=/var/log/flower/error.log
autostart=true
autorestart=true
startsecs=10
@shudarshon
shudarshon / rabbitmq_queue_clean
Last active July 8, 2017 07:23
This cronjob delete all rabbitmq queue on reboot which eliminates celery worker hang up.
sudo crontab -e
@reboot sudo -u rabbitmq rabbitmqctl stop_app && sudo -u rabbitmq rabbitmqctl force_reset && sudo -u rabbitmq rabbitmqctl start_app
@shudarshon
shudarshon / celerybeat_alert.sh
Created July 7, 2017 17:52
This script checks if celerybeat is service is down then it will notify admin via email then it will keep the celerybeat running.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/ubuntu
status=$(sudo supervisorctl status celerybeat | grep -o FATAL)
if [ "$status" == "FATAL" ]
then
echo "Celerybeat service is Down!" | mail -s "Celerybeat Down" admin@domain.com, admin2@domain.com, admin3@domain.com > /dev/null 2>&1
sudo supervisorctl restart all > /dev/null 2>&1
status=$(sudo supervisorctl status celerybeat | grep -o RUNNING)
if [ "$status" == "RUNNING" ]
then