django 项目常用开发部署shell脚本

假设我的application name 为DjangoRESTImage;

假设我的数据库使用sqlite3;

删除数据库脚本:rm_db.sh

rm -rf db.sqlite3
rm -rf DjangoRESTImage/migrations/

 

python manage.py  启动 run_as_python.sh

python manage.py migrate
python manage.py makemigrations DjangoRESTImage
python manage.py migrate DjangoRESTImage
python manage.py runserver 0.0.0.0:48080

 

uwsgi 启动程序 run_as_server.sh

python manage.py migrate
python manage.py makemigrations DjangoRESTImage
python manage.py migrate DjangoRESTImage
uwsgi --ini ./deploy-file/uwsgi.ini

 

简单uwsgi脚本 uwsgi.ini

[uwsgi]
#the local unix socket file than commnuincate to Nginx
socket = 127.0.0.1:48080
# the base directory (full path)
chdir = /home/dalaoshe/DjangoREST

# Django's wsgi file
wsgi-file = DjangoREST/wsgi.py
# maximum number of worker processes
processes = 4
#thread numbers startched in each worker process
threads = 2
 
#monitor uwsgi status
stats = 127.0.0.1:9191
# clear environment on exit
vacuum          = true

 

[uwsgi]
#the local unix socket file than commnuincate to Nginx

env LANG="zh_CN.UTF-8"
env LANGUAGE="zh_CN.UTF-8"
;env LANG="en_US.UTF-8"
;env LANGUAGE="en_US.UTF-8"
socket = 127.0.0.1:48080
# the base directory (full path)

chdir = /home/home/
# Django's wsgi file
wsgi-file = /home/home/DjangoREST/wsgi.py

;module = DjangoREST.wsgi:application
# maximum number of worker processes
processes = 4
#thread numbers startched in each worker process
threads = 2

#monitor uwsgi status
stats = 127.0.0.1:9191
# clear environment on exit
vacuum          = true
daemonize =/var/log/uwsgi/django_uwsgi_new.log
;logto =/var/log/uwsgi/django_uwsgi.log

 

 

nginx部署配置,包含前端react代码 nginx.conf

user root;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 1024;
    # multi_accept on;
}

http {
    include /etc/nginx/mime.types;
    default_type  application/octet-stream;

server {

    listen 8080;
    server_name localhost;


    location / {
        root /home/dalaoshe/ant-design-pro/dist;
        index  index.html;
        try_files $uri $uri/ /index.html;
        }

    location /user {
        proxy_pass http://localhost:58080/user;
    }
}

server {
        listen       58080;
        server_name  localhost;

        location / {
            uwsgi_pass  127.0.0.1:48080;
            include uwsgi_params;
            index  index.html index.htm;
            client_max_body_size 35m;
        }
        location /static {
            alias /home/home/DjangoREST/collected_static;
        }
    }

#    include /etc/nginx/conf.d/*.conf;
     include /etc/nginx/sites-enabled/*;
}

 

posted @ 2018-11-15 12:17  Adamanter  阅读(937)  评论(0编辑  收藏  举报