I’m trying to build a Jenkins job that (1) pulls the latest from
Git
, (2) builds myDjango
project, and (3) restartsgunicorn
andnginx
.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 togunicorn.service
? What are some strategies I can use to handle this?
Answer
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.
Attribution
Source : Link , Question Author : ttmtran , Answer Author : daks