在Ubuntu 15.10上“单位gunicorn.service无法加载:没有这样的文件或目录”?
当设置一个新的Ubuntu 15.10 x64服务器运行nginx,gunicorn,django作为sudo用户。 我通过运行service gunicorn start
收到错误消息(作为root,是的,这是一个坏主意):
Failed to start gunicorn.service: Unit gunicorn.service failed to load: No such file or directory.
从活跃的virtualenv我可以开始使用gunicorn:
任何想法将非常感谢如何解决这个问题,因为我已经从各种网络搜索中尝试了很多建议,这些建议提到了与此类似的问题而没有运气。
My gunicorn file is at `/etc/init/gunicorn.conf` and is configured as follows: description "Gunicorn application server handling myproject" start on runlevel [2345] stop on runlevel [!2345] respawn setuid myuser setgid www-data chdir /home/myuser/myproject exec myprojectenv/bin/gunicorn --workers 3 --bind unix:/home/myuser/myproject/myproject.sock myproject.wsgi:application
这个问题与此相同,但我没有评论的权限,用户似乎已经找到了systemd的答案。 最初的问题源于遵循Ubuntu 15.10的本指南 。 我尝试检查该页面上的评论部分,使用我的google fu和各种网站进行搜索。
简单的帮助将非常适合Ubuntu的新人。
当您需要使用Systemd时,您正在尝试使用Upstart。 因此,您需要使用Systemd配置,而不是Upstart。
取自http://docs.gunicorn.org/en/stable/deploy.html
Systemd
在Linux系统上开始普遍使用的工具是Systemd。 以下是用于在systemd中设置Gunicorn启动的配置文件以及Gunicorn将监听的接口。 套接字将由systemd管理:
/lib/systemd/system/gunicorn.service:
[Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target [Service] PIDFile=/run/gunicorn/pid User=someuser Group=someuser WorkingDirectory=/home/someuser ExecStart=/home/someuser/gunicorn/bin/gunicorn --pid /run/gunicorn/pid test:app ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s TERM $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
gunicorn.socket:
[Unit] Description=gunicorn socket [Socket] ListenStream=/run/gunicorn/socket ListenStream=0.0.0.0:9000 ListenStream=[::]:8000 [Install] WantedBy=sockets.target
tmpfiles.d / gunicorn.conf:
d /run/gunicorn 0755 someuser someuser -
在运行curl http:// localhost:9000 /之后 ,Gunicorn应该启动,你应该在日志中看到类似的内容:
2013-02-19 23:48:19 [31436] [DEBUG]套接字激活套接字:unix:/ run / gunicorn / socket,http://0.0.0.0:9000,http:// [:]::8000