做网站需要了解什么东西,长春网站建设公司怎么样,中国网络营销平台,百度门户网站以python django gunicorn ubuntu20 为例
首先python环境用conda,查看虚拟环境的目录 conda env list 找到python的路径
写一个启动服务器的脚本 start.sh
#!/bin/bash
source /home/ema/app/miniconda/bin/activate subsys # 替换为 conda 的实际路径
cd /home/xx/xx/…以python django gunicorn ubuntu20 为例
首先python环境用conda,查看虚拟环境的目录 conda env list 找到python的路径
写一个启动服务器的脚本 start.sh
#!/bin/bash
source /home/ema/app/miniconda/bin/activate subsys # 替换为 conda 的实际路径
cd /home/xx/xx/subsystem # 切换到 项目配置目录,此目录下有 gunicorn的配置文件gunicorn_conf.py
gunicorn -c gunicorn_conf.py application.asgi:application # 写一个服务 sudo vim /etc/systemd/system/my-service.service 因为 Ubuntu的系统服务放在 /etc/systemd/system这个目录下,创建的服务文件以service结尾
[Unit]
Descriptionsubsystem App
Afternetwork.target[Service]
Typesimple
ExecStart/bin/bash -c /home/xx/xx/start.sh # 启动脚本的位置名称
Restartalways # 保活
RestartSec3 # 3s一重启[Install]
WantedBymulti-user.target保存并关闭文件. 3. 重新加载服务配置文件
sudo systemctl daemon-reload 启用自启动服务 sudo systemctl enable my-service 启动服务
sudo systemctl start my-service现在你的服务应该已经成功创建并启动了。如果你希望停止服务可以使用以下命令
sudo systemctl stop my-service如果你希望查看服务的状态可以使用以下命令
sudo systemctl status my-service查看服务的启用状态
systemctl is-enabled 服务名