dduk-ddak / coding-night-live

Web-based Communication Application for Codelabs
Other
62 stars 11 forks source link

DEBUG=False #65

Closed punkyoon closed 7 years ago

punkyoon commented 7 years ago

실제 서비스 배포시에는 settings.py의 옵션을 DEBUG=False로 해두어야한다고 합니다.

하지만, 위의 옵션으로 설정하면 기존에 사용되던 정적파일을 서버에서 제대로 사용하지 못하게 됩니다.

django에서도 기본 서버실행 명령인 runserver를 지양하라 했고, nginx등 다른 서버를 사용할 때를 대비해서라도 필요한 옵션인만큼 이에 대한 대비를 해야합니다.

  1. STATIC_ROOT 설정
  2. collectstatic명령으로 기존 정적파일 collect
  3. 이 외의 사항은 django 공식문서, 기타 자료 참고!

덧붙이자면, 이후 nginx등의 다른 서버를 사용할 때를 생각하여 daphne사용도 고려해야할 것 같습니다.

punkyoon commented 7 years ago

nginx with daphne

nginx with django

punkyoon commented 7 years ago

nginx 8000번 포트를 연 경우, daphne로 8001포트를 열고.. localhost:8001로 접속이 가능하다.

punkyoon commented 7 years ago

sudo service nginx start

python3 manage.py runworker

daphne -p 8001 coding_night_live.asgi:channel_layer

실행해야할 명령이 너무 많다..

punkyoon commented 7 years ago

너무 어려워요..

nginx + uWSGI + django

물론 uWSGI를 사용하지 않으므로 나머지 다른 것만 참고해봐야겠어요.

punkyoon commented 7 years ago

localhost

coding-night-live_nginx.conf

  1. server_name localhost
  2. proxy_pass http://localhost:8001

command

  1. redis-server
  2. python3 manage.py runworker
  3. daphne -p 8001 coding_night_live.asgi:channel_layer
  4. service nginx start

80 deploy

coding-night-live_nginx.conf

  1. server_name {{ server_domain }}
  2. proxy_pass http://0.0.0.0:8001

command

  1. redis-server
  2. python3 manage.py runworker
  3. daphne -b 0.0.0.0 -p 8001 coding_night_live.asgi:channel_layer (b옵션 추가됨.)
  4. service nginx start

80포트로 접속시 정상적인 static file들이 보임

juice500ml commented 7 years ago

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ와우 해보겟습니드..

punkyoon commented 7 years ago

issue_65브랜치에 로컬에서 nginx conf파일 완성했고, 다른 여러 환경에서 잘 동작하는거 확인했습니다.

이제 남은건 docker에서 바로 이용할 수 있게 nginx 세팅하는 부분이네요.. docker 브랜치에서 계속 작업 진행하고, 이 부분까지 완료되면 issue_65 브랜치와 병합해서 master 브랜치에 업로드할 예정입니다.

juice500ml commented 7 years ago

https://github.com/dduk-ddak/coding-night-live/pull/78 ;)