-1

I'm trying to build a Jenkins job that (1) pulls the latest from Git, (2) builds my Django project, and (3) restarts gunicorn and nginx.

However, when I try to restart gunicorn, I get the following error:

jenkins@digitalocean:/$ /usr/sbin/service gunicorn restart 
Failed to restart gunicorn.service: Access denied

I think this is because the user jenkins doesn't have access to gunicorn.service? What are some strategies I can use to handle this?

0

As said previously, your jenkins user simply doesn't have the permissions to restart the gunicorn process.

You can in fact give it sudo rights, but another solution is to use virtualenv to isolate your Python application environnement. This way the virtualenv can belong to jenkins user, the process too, and he can restart it.

0
  1. hint: it's in The /usr/sbin Directory.

    The /usr/sbin directory contains non-vital system utilities that are used after booting (i.e., starting the system) by the system administrator.

  2. hint: it's a service.

  3. hint: You got Access denied

Hat-trick! We have sudo for these situations.

sudo service gunicorn restart
  • 1
    Since the jenkins user probably doesn't have permission to sudo, you might need to give it permission to run the service command with it. See, for example: unix.stackexchange.com/questions/192706/… – Matt Jun 11 '17 at 19:58
  • The jenkins user doesn't have permissin to sudo. I'm still trying to make it work, and I'll try your link, Matt. Thanks! – ttmtran Jun 12 '17 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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