1

I usually do a sudo service gunicorn start to start the gunicorn service, so my app whenever needs to create a folder the ownership belongs to the user logged in when ran the command and the group belongs to sudo. My question is, why when I try to call the service as service gunicorn start I get the error

start: Rejected send message, 1 matched rules; type="method_call", sender=":1.20" (uid=1001 pid=10684 comm="start gunicorn ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")

I know that it has to do with permissions but I can not fully understand what this message mean and how I can call the service without sudo. Thank you in advance

1 Answer 1

1

Linux services must be started by root, unless you use sudo. For instance, if you check your scripts services:

lgallard@host:~$ ls -l /etc/init.d/* | head
-rwxr-xr-x 1 root root  2243 abr  3  2014 /etc/init.d/acpid
-rwxr-xr-x 1 root root  2014 feb 19  2014 /etc/init.d/anacron
-rwxr-xr-x 1 root root  9974 ene  7  2014 /etc/init.d/apache2
-rwxr-xr-x 1 root root  4596 mar 27  2014 /etc/init.d/apparmor
-rwxr-xr-x 1 root root  2801 oct 30  2014 /etc/init.d/apport

You will realize all belongs to root.

On the other hand, you can check if gunicorn has a flag to run the process as a daemon, and check if it can run with a predefined user. But I guess the best way is by using Linux services, so you can enable or disable them at startup using tools like sysv-rc-conf or chkconfig.

Best regards!

2
  • Thank you very much for your answer.I will need some time to study it and understand it.Now in order to elaborate more I would have to confess that my optimal goal is not to start the service as non sudo,but to debug the following issue:On my dev server, when I am logged in as user "user1" and start PyCharm with sudo and run my application a folder is created with ownership:group = user1:sudo, whereas when I start PyCharm as non sudo the same folder is created as user1:user1.So I wanted to verify that the same holds in the production server (that the gunicorn runs). Thank you again!
    – pebox11
    Dec 5, 2015 at 3:05
  • I even tried to remove group sudo from the user but the folder is created as user1:sudo and not as user1:user1 which is the desired and I was hoping to accomplish by running gunicorn as a non sudo.
    – pebox11
    Dec 5, 2015 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.