Git Product home page Git Product logo

Comments (32)

tianke0711 avatar tianke0711 commented on August 16, 2024

还有我以前用了创建 uWSGI 配置文件来运行。我不知道用gunicorn -w 4 wsgi:app后 断开服务器 会一直运行吗?

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

我在看你的博客:https://2dogz.cn/blog/article/2/ 我看你是在/etc/nginx/sites-available/里配置文件。 我以前部署在aws ec2 是在 /etc/nginx/sites-enabled/建的配置文件文件 我想问一下有啥区别。

  • sites-enabled 下的文件,会作为 nginx.conf 的一部分加载
  • sites-enabled 下的用于存放 sites-available 中文件的软连接
    这种问题其实你自己搜一下就知道结果,或者看Nginx的文档

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

还有我以前用了创建 uWSGI 配置文件来运行。我不知道用gunicorn -w 4 wsgi:app后 断开服务器 会一直运行吗?

你连接了云服务器在ssh终端执行gunicorn你断开SSH之后进程肯定会死掉,有三种方法可以让gunicorn一直运行

  1. /etc/systemd/system/目录下新建一个service,然后通过service或者systemctl启动这个service
  2. 配合supervisor具体方法见 https://2dogz.cn/blog/article/3/
  3. 使用nohup的方式运行gunicorn

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 OK 谢谢。我问一下我再次gunicorn -w 4 wsgi:app出现了下面问题。网页也打不开。
gunicorn -w 4 wsgi:app
[2021-10-29 03:12:42 +0000] [20653] [INFO] Starting gunicorn 20.1.0
[2021-10-29 03:12:42 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000)
[2021-10-29 03:12:42 +0000] [20653] [ERROR] Retrying in 1 second.
[2021-10-29 03:12:43 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000)
[2021-10-29 03:12:43 +0000] [20653] [ERROR] Retrying in 1 second.
[2021-10-29 03:12:44 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000)
[2021-10-29 03:12:44 +0000] [20653] [ERROR] Retrying in 1 second.
[2021-10-29 03:12:45 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000)
[2021-10-29 03:12:45 +0000] [20653] [ERROR] Retrying in 1 second.
[2021-10-29 03:12:46 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000)
[2021-10-29 03:12:46 +0000] [20653] [ERROR] Retrying in 1 second.
[2021-10-29 03:12:47 +0000] [20653] [ERROR] Can't connect to ('127.0.0.1', 8000)

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

@weijiang1994 OK 谢谢。我问一下我再次gunicorn -w 4 wsgi:app出现了下面问题。网页也打不开。 gunicorn -w 4 wsgi:app [2021-10-29 03:12:42 +0000] [20653] [INFO] Starting gunicorn 20.1.0 [2021-10-29 03:12:42 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000) [2021-10-29 03:12:42 +0000] [20653] [ERROR] Retrying in 1 second. [2021-10-29 03:12:43 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000) [2021-10-29 03:12:43 +0000] [20653] [ERROR] Retrying in 1 second. [2021-10-29 03:12:44 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000) [2021-10-29 03:12:44 +0000] [20653] [ERROR] Retrying in 1 second. [2021-10-29 03:12:45 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000) [2021-10-29 03:12:45 +0000] [20653] [ERROR] Retrying in 1 second. [2021-10-29 03:12:46 +0000] [20653] [ERROR] Connection in use: ('127.0.0.1', 8000) [2021-10-29 03:12:46 +0000] [20653] [ERROR] Retrying in 1 second. [2021-10-29 03:12:47 +0000] [20653] [ERROR] Can't connect to ('127.0.0.1', 8000)

你这报错是因为你本地8000端口已经被占用了。不能访问的原因是因为你启动在127.0.0.1上面,如果需要通过ip:port远程访问,执行下面的命令

gunicorn -w 4 -b 0.0.0.0:8000 wsgi:app

通过下面的命令杀死你已经启动的8000端口进程

ps -aux | grep gunicorn 
sudo kill -9 gunicorn_pid # 上面找到的gunicorn进程的pid

红圈里面的就是pid
图片

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

这种博客的小网站gunicorn就够用了,没必要上Nginx进行反向代理,杀鸡焉用宰牛刀?

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

Hi @weijiang1994 我的
[program:Blogin]
command=/home/ubuntu/Blogin/bash.sh
directory=/home/Blogin/SciSci
user=root
autostart=true
*autorestart=true
stopasgroup=true
killasgroup=true
sudo supervisorctl

#! /bin/bash
cd /home/ubuntu/Blogin
exec gunicorn -w 4 wsgi:app

但是运行不成功
sudo service supervisor restart
sudo supervisorctl

Blogin FATAL Exited too quickly (process log may have details)

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

Blogin FATAL Exited too quickly (process log may have details)

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

你意思是process log?这个在哪里process log?

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

一般在/var/log/supervisor目录

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 我加了一个startsecs=0 在blog.conf文件中。
虽然可以:RUNNING pid 7138, uptime 0:00:00
但是我发现网页打不开。
502 Bad Gateway
nginx/1.14.0 (Ubuntu)

#! /bin/bash
cd /home/ubuntu/Blogin
exec gunicorn -w 4 wsgi:app

为啥你的blogin文件下是: exec gunicorn -c gunicorn_conf.py wsgi:app
多了一个gunicorn_conf.py

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

502说明你NGINX反向代理没有配置正确

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 我开始只用gunicorn -w 4 wsgi:app 网页可以打开啊

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

不清楚你怎么配置的,我也搞不清楚原因。

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 为啥大家使用不同呢
https://blog.csdn.net/guolindonggld/article/details/83386920

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 我感觉是不是安装问题, 为啥是python2版本的supervisor
sudo apt-get install supervisor
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python python-meld3 python-minimal python-pkg-resources python2.7 python2.7-minimal
Suggested packages:
python-doc python-tk python-setuptools python2.7-doc binfmt-support supervisor-doc
The following NEW packages will be installed:
libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python python-meld3 python-minimal python-pkg-resources python2.7 python2.7-minimal supervisor
0 upgraded, 10 newly installed, 0 to remove and 36 not upgraded.
Need to get 0 B/4382 kB of archives.

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

不是很清楚,我的ubuntu1604没有问题

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 你好 commnd加上了/usr/bin/python3 /home/ubuntu/.local/bin/gunicorn -w 4 wsgi:app supervisor OK啦 还有user改成ubuntu 成功了。
但是我发现我chrome浏览器无法域名访问,只能用ip地址访问,但是safari浏览器可以域名访问。并且手机上访问苹果浏览器也不行。很奇怪。不知道怎么解决。

我记得当时只是单纯在terminal运行gunicorn -w 4 wsgi:app 时候域名可以访问。

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

我今天写博客时候 点击提交后出现了这个问题:
/10/31 00:59:28 [error] 10234#10234: *1338 client intended to send too large body: 1539034 bytes,

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

Nginx中设置的最大文件大小过小

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 哪个文件 这个吗do vim /etc/nginx/sites-available/default?

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

自己搜一下

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 OK啦 修改完。加了client_max_body_size 1024M; 在/etc/nginx/nginx.conf里。
@weijiang1994 这个在哪里修改啊 我想修改成支持jpeg格式。
还有我上传我手机以前拍摄的照片为啥不可以啊 说直接受jpd和png图片。但是我选择实时拍摄,然后上传照片就可以。

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 我修改以前的博客,但是点击提交后出现了错误
FileNotFoundError: [Errno 2] No such file or directory: '/Users/xx/PycharmProjects/Blogin/history/41590fc30458a88c584b7c8dedfa5749.txt'

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

这种错误你应该知道怎么解决吧?

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 我加了history文件夹。

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 你是不是登录我的后台啦

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

@weijiang1994 你是不是登录我的后台啦

我没登录啊,我只是注册了账号而已...

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 好的 我得修改一下代码。我看你超级管理员

from blogin.

weijiang1994 avatar weijiang1994 commented on August 16, 2024

你可以改一下代码,因为我当初把通过我的邮箱注册账号自动设置为超级管理员

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 好的

from blogin.

tianke0711 avatar tianke0711 commented on August 16, 2024

@weijiang1994 到此为止,谢谢你的指导。我后面会对网站进行修改一下 增加一些我的特色。不过暂时只是写写博客,时间有限。

from blogin.

Related Issues (20)

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.