单位gunicorn.service无法加载:没有这样的文件或目录

当设置一个新的Ubuntu 15.10 x64服​​务器运行nginx,gunicorn,django作为sudo用户。 我通过运行sudo service gunicorn start收到错误消息:

 Failed to start gunicorn.service: Unit gunicorn.service failed to load: No such file or directory. 

从活跃的virtualenv我可以开始使用gunicorn:

 gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application 

任何想法将非常感谢如何解决这个问题,因为我已经从各种网络搜索中尝试了很多建议,这些建议提到了与此类似的问题而没有运气。

我的gunicorn文件位于/etc/init/gunicorn.conf ,配置如下:

 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 

您需要在/etc/systemd/system创建gunicorn.service 。 接下来,将此代码添加到其中并相应地替换usermyprojectmyprojectenv

 [Unit] Description=gunicorn daemon After=network.target [Service] User=user Group=nginx WorkingDirectory=/home/user/myproject ExecStart=/home/user/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:/home/user/myproject/myproject.sock myproject.wsgi:application [Install] WantedBy=multi-user.target