Giter VIP home page Giter VIP logo

bookreview's Introduction

#Deployment:

  1. you have put every depedencies in requirements.txt
  2. init .gitignore to skip *.pyc and some lib files
  3. Install gunicorn
  4. Install nginx
  5. Configure to add gunicorn like a unit service in systemd: create a file in /etc/systemd/system/gunicorn.service with content like this:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=huy.nv.ngo
Group=www-data
WorkingDirectory=/home/huy.nv.ngo/BookReview
ExecStart=/home/huy.nv.ngo/BookReview/bin/gunicorn --access-logfile /var/log/belt_reviewer/gunicorn-access.log --error-logfile /var/log/belt_reviewer/gunicorn-error.log --workers 3 --bind unix:/home/huy.nv.ngo/BookReview/belt_reviewer.sock belt_reviewer.wsgi:application
[Install]
WantedBy=multi-user.target

after that , first we have to use systemctl to reload all daemon sudo systemctl daemon-reload after we reload, start gunicorn daemon sudo systemctl start gunicorn after we start this daemon => enable it sudo systemctl enable gunicorn

Tips: if we want to specific log for it use --access-logfile parameter and --error-logfile parameter

Please chmod for the log path before start gunicorn

So if you change any thing in service script => call reload daemon So if you want to change source code in django => restart gunicorn to update this source code

6 Configure for nginx create a new site_avaiable: vim /etc/nginx/sites-available/belt_reviewer

server {
  listen 8000;
  server_name 0.0.0.0;
  location = /favicon.ico { access_log off; log_not_found off; }
  location /static/ {
      root /home/huy.nv.ngo/BookReview;
  }
  location / {
      include proxy_params;
      proxy_pass http://unix:/home/huy.nv.ngo/BookReview/belt_reviewer.sock;
  }
}

after that sudo ln -s /etc/nginx/sites-available/{{projectName}} /etc/nginx/sites-enabled sudo nginx -t

sudo rm /etc/nginx/sites-enabled/default sudo service nginx restart

Tip to migrate data from Sqlite3 to mysql

Step to migrate data from sqlite3 to mysql
1.python manage.py dumpdata > datadump.json
2. Change settings.py to your mysql
3. Make sure you can connect on your mysql (permissions,etc)
4. python manage.py migrate --run-syncdb
5. Exclude contentype data with this snippet

from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
quit()

6.python manage.py loaddata datadump.json

bookreview's People

Contributors

huyngopt1994 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.