Django:
反向生成models:
python manage.py inspectdb > 路径/models.py
依赖文件生成
pip freeze > requirements.txt
取到models所有字段:
field = models.XXX.objects.first()._meta.fields for i in field: print(i.name)
日志标简易配置:
logging.basicConfig(level=logging.ERROR, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s', datefmt=' %Y-%m-%d %H:%M:%S', filename='bug.log', filemode='a', )
Linux操作:
查看可用端口:
sudo service iptables status
已在运行的端口:ps -ef|grep python
杀死所有9011端口相关的tcp进程fuser -k 9011/tcp
一般后台运行nohup python manage.py runserver 0.0.0.0:9011 &
supervisor的用法
1 编写配置文件
vim /etc/supervisor/conf.d/xxxx.ini
2 参考配置文件
用uwsgi运行[program: inventory]directory=/home/ywc/inventorycommand= /home/ywc/pycharm/ye_test/bin/python3.6 /home/ywc/inventory/manage.py runserver 0.0.0.0:9013numprocs=1numprocs_start=1autostart=trueautorestart=trueprocess_name=%(program_name)s直接运行[program: talk_django2.0-master]directory=/home/mbox/python_project/Talk_django2.0-mastercommand= /home/mbox/python_project/Talk_django2.0-master/py3env/bin/uwsgi --ini /home/mbox/python_project/Talk_django2.0-master/uwsgi.ininumprocs=1numprocs_start=1autostart=trueautorestart=trueprocess_name=%(program_name)s
3 重新加载配置
supervisorctl reload