我试图使用Amazon EC2 Django__、Gunicorn__和Nginx__部署一个基本应用程序。我将应用程序git clone_d放入AWS Ubuntu实例中,并运行Django 1.10__。
我能够使用Gunicorn 运行我的应用程序,命令如下.
gunicorn --bind 0.0.0.0:8000 blackspruceherbals.wsgi:application
但是,当我试图为Gunicorn__.创建一个upstart文件时,遇到了麻烦。文件路径如下.
/etc/init/gunicorn.conf
和暴发户代码看起来如下.
description "Gunicorn application server handling black spruce herbals"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid ubuntu
setgid www-data
chdir /home/ubuntu/websitename/
exec bsh_env/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/websitename/websitename.sock websitename.wsgi:application当我跑的时候.
sudo service gunicorn start
我得到以下错误.
Failed to start gunicorn.service: Unit gunicorn.service not found.
怎么回事?我在网上搜索过答案,但什么也没找到。你能看到明显的我做错了什么吗?提前谢谢。
发布于 2018-10-21 06:52:11
添加到赫里斯托菲德斯答案:
1)打开和创建systemd服务文件:
$ sudo nano /etc/systemd/system/gunicorn.service2)将以下内容写入文件:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=name_of_user
Group=name_of_user
WorkingDirectory=/home/name_of_user/myproject
ExecStart=/home/name_of_user/myproject/virtualenv_directory/bin/gunicorn --
access-logfile - --workers 3 --bind unix:/home/name_of_user/myproject/myproject.sock myproject.wsgi:application
[Install]
WantedBy=multi-user.target3)启动服务:
$ sudo systemctl start gunicorn4)启用服务:
$ sudo systemctl enable gunicorn5)检查进程的状态:
$ sudo systemctl status gunicorn欲了解更多信息,请访问这里
谢谢。:)
发布于 2016-11-21 07:59:38
自从Ubuntu15.04以来,upstart已经被systemd所取代。您需要创建一个文件/etc/systemd/gunicorn.service,它的语法与upstart文件不同。常见问题可以帮助您启动,引用是man systemd.service。
https://stackoverflow.com/questions/40711747
复制相似问题