0

I have deployed Django application with gunicorn + nginx + postgres. I am using digitalocean ubuntu server.Which sometimes once in a month reboots automatically so that application goes down. How to auto restart the application? my start-up script:

#!/bin/bash
#activate virtual env
echo Activate vitualenv.
source /home/wrangler_env/bin/activate


#restart database
#echo restarting database
#sudo service postgresql restart
# Start Gunicorn processes
echo Starting Gunicorn.
gunicorn wrangler.wsgi:application --bind=0.0.0.0:1312 --daemon


#restart nginx
echo Restarting Nginx
service nginx restart

This script I re-run manually once the server reboot automatically.

Sidhartha
  • 988
  • 4
  • 19
  • 39
  • 2
    You don't say anything about how you are starting the application. Usually you would write a systemd or upstart file to start gunicorn on boot, have you not done this? – Daniel Roseman Apr 02 '18 at 18:27
  • I have updated the question, How to run this script automatically once the server reboot or is there any other solution? – Sidhartha Apr 03 '18 at 05:29
  • Exactly like I said: you should write a systemd or upstart script for gunicorn. nginx will already have one. – Daniel Roseman Apr 03 '18 at 07:00
  • Help me to write systemd script.actually, I don't have the idea on that. – Sidhartha Apr 03 '18 at 07:02

0 Answers0