{"id":18406996,"url":"https://github.com/xhongc/dj-chat","last_synced_at":"2025-04-07T08:32:35.504Z","repository":{"id":39720297,"uuid":"278318238","full_name":"xhongc/dj-chat","owner":"xhongc","description":"🔥django-channels + bootstrap + jquery 聊天功能","archived":false,"fork":false,"pushed_at":"2022-12-08T11:06:14.000Z","size":3004,"stargazers_count":100,"open_issues_count":8,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-22T15:51:39.109Z","etag":null,"topics":["chat","websocket"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xhongc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-09T09:15:42.000Z","updated_at":"2025-01-29T07:57:02.000Z","dependencies_parsed_at":"2023-01-25T11:15:51.977Z","dependency_job_id":null,"html_url":"https://github.com/xhongc/dj-chat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xhongc%2Fdj-chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xhongc%2Fdj-chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xhongc%2Fdj-chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xhongc%2Fdj-chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xhongc","download_url":"https://codeload.github.com/xhongc/dj-chat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247620534,"owners_count":20968229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chat","websocket"],"created_at":"2024-11-06T03:11:49.942Z","updated_at":"2025-04-07T08:32:33.701Z","avatar_url":"https://github.com/xhongc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Websocket 聊天系统\n## 技术栈\n\u003cbr\u003e\ndjango-channels + bootstrap + jquery \n\n项目地址参考：http://106.55.162.109:8888/ 账号：admin 密码：xhongc\n## 界面截图\n![](https://s1.ax1x.com/2020/07/28/aVKVhD.png)\n![](https://s1.ax1x.com/2020/07/11/Ul8LZ9.png)\n![](https://s1.ax1x.com/2020/07/11/UlYYKU.png)\n## 安装\n1. pip install -r requirement.txt\n2. [安装运行redis](https://www.runoob.com/redis/redis-install.html)\n3. python manage.py migrate #初始化数据库\n4. python manage.py createsuperuser #创建管理员账户\n4. `python manage.py runserver 8088` or \n`daphne -b 127.0.0.1 -p 8088 dj_chat.asgi:application`\n5. 访问127.0.0.1:8088 \n\n## 部署\n\u003e nginx + daphne + gunicorn + supervisor\n- gunicorn，green unicorn 简称，unix系统的wsgi http服务器\n处理符合wsgi的接口，使得底层处理与上层业务分开，Django仅负责业务层的处理，这里使用主要是官方推荐，uwsgi服务器使用的人也比较多\n- daphne 支持HTTP, HTTP2 和 WebSocket 的asgi的服务器，这里主要是处理WebSocket 的请求\n- supervisor 进程管理器，当web项目存在多个进程需要处理时，方便统一管理，如服务器down机重启时自启动等\n- nginx 静态资源处理和请求的分发等，http请求指向gunicorn进程，websocket请求指向daphne进程等\n\u003e tips: gunicorn 和 daphne 开不同的端口[！](https://github.com/xhongc/dj-chat/blob/master/supervisor.conf)\n#### nginx 配置\n```nginx\nserver {\n        listen 80;\n        server_name 106.55.162.109;\n        charset utf-8;\n        client_max_body_size 75M;\n        location /static {\n            alias /home/ubuntu/dj-chat/static;\n        }\n        access_log /home/ubuntu/chat_log/access.log;\n        error_log /home/ubuntu/chat_log/error.log;\n        location / {\n            proxy_pass http://127.0.0.1:8000;\n            include /etc/nginx/uwsgi_params;\n        }\n        location /ws {\n            proxy_pass http://127.0.0.1:8001;\n            proxy_http_version 1.1;\n            proxy_set_header Upgrade $http_upgrade;\n            proxy_set_header Connection \"upgrade\";\n            proxy_redirect     off;\n            proxy_set_header   Host $host;\n            proxy_set_header   X-Real-IP $remote_addr;\n            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;\n            proxy_set_header   X-Forwarded-Host $server_name;\n            proxy_read_timeout  36000s;\n            proxy_send_timeout  36000s;\n        }\n        root /var/www/html;\n        index boot_chat.html;\n}\n\n```\n## Docker 部署\n```shell\ndocker-compose build\ndocker-compose up -d\n```\n详细流程跳转到[Docker部署应用 Django+daphne+Gunicorn+Nginx+Redis](https://xhongc.github.io/docker-django-daphne-gunicorn-nginx.html)\n## 后续开发计划\n- [ ] 开发音乐机器人（多人同步听歌）\n8. 玩家在线离线头像变灰\n9. 重新定义消息返回结构\n- [ ] 开发视频机器人（多人视频）\n- [ ] vue 重构前端\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxhongc%2Fdj-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxhongc%2Fdj-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxhongc%2Fdj-chat/lists"}