Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Running Pyramid with Gunicorn as non root user
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Huang  
View profile  
 More options Jul 4 2012, 11:32 pm
From: Mark Huang <zhengha...@gmail.com>
Date: Wed, 4 Jul 2012 20:32:05 -0700 (PDT)
Local: Wed, Jul 4 2012 11:32 pm
Subject: Running Pyramid with Gunicorn as non root user

Hi Everyone,

I currently have 2 servers A and B, both running on Debian.  Server A was
setup 1 month ago with Gunicorn 1.4.3.  I created a new linux user called
'web', with shell access and a home directory.  The virutalenv is managed
by virtualenvwrapper in the home directory.  So what I would do to start my
pyramid application would be to login as root and switch to the 'web' user
(su - web) and run gunicorn like so:  

    gunicorn_paster -w 5 -t 80 --log-file=/somewhere/with/logs -D
production.ini

This works!

Server B was setup yesterday.  It is using Gunicorn 1.4.5.  My boss wants
me to use the default www-data user and group instead of creating a
separate user and group.  So I created my virtualenv to run my pyramid
application as the 'root' user.  All of my code and logs live in the /srv
directory and sub-directories.  I gave chown-ed the srv directory with
www-data:www-data.  Now....when I run gunicorn paster, I had to specify a
user and group to run as using the '-u' and '-g' flag as stated in their
documentation <http://gunicorn.org/configure.html#user>:

    gunicorn_paster -w 5 -t 80 --log-file=/somewhere/with/logs -u www-data
-g www-data -D production.ini

However, this gave an error.  I added the --log-level=debug into it and the
error says:  

2012-07-05 11:13:35 [29578] [INFO] Worker exiting (pid: 29578)
/paste/deploy/loadwsgi.py", line 296, in loadcontext
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
line 320, in _loadconfig
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
line 454, in get_context
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
line 476, in _context_from_use
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
line 406, in get_context
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
line 296, in loadcontext
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
line 328, in _loadegg
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
line 620, in get_context
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
line 646, in find_egg_entry_point
  File
"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/setuptools-0.6c11 -py2.7.egg/pkg_resources.py",
line 1954, in load
  File "/srv/web/prod/rhino/rhino/__init__.py", line 2, in <module>
    from pyramid.config import Configurator
ImportError: No module named pyramid.config

The really weird thing is that, if I open up a python console within my
virtualenv, I am able to import that module!!  What's going on?  I suspect
it is permissions related or something and that I am unable to run Gunicorn
as a non root user (without shell access).

Regards,
Mark Huang


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Huang  
View profile  
 More options Jul 5 2012, 1:00 am
From: Mark Huang <zhengha...@gmail.com>
Date: Wed, 4 Jul 2012 22:00:47 -0700 (PDT)
Local: Thurs, Jul 5 2012 1:00 am
Subject: Re: Running Pyramid with Gunicorn as non root user

I'd like to add on to this:

If I were to run the command without the -u flag, my pyramid application
will get started with no problems at all, just that it will be running as
the root user.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Forkel  
View profile  
 More options Jul 5 2012, 1:02 am
From: Robert Forkel <xrotw...@googlemail.com>
Date: Thu, 5 Jul 2012 07:02:25 +0200
Local: Thurs, Jul 5 2012 1:02 am
Subject: Re: Running Pyramid with Gunicorn as non root user
The following line (with parameters replaced) in upstarts script block
does work for me

exec /path/to/virtualenv/bin/gunicorn --pid=$pid --name="$name"
--user=$name --group=$name \
--access-logfile=$log_dir/access.log
--error-logfile=$log_dir/error.log $config 2\

>>$log_dir/error.log

The user account I run gunicorn under is not www-data, though, and
does have a shell.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cornelius Kölbel  
View profile  
 More options Jul 5 2012, 1:22 am
From: Cornelius Kölbel <cornelius.koel...@lsexperts.de>
Date: Thu, 5 Jul 2012 07:22:20 +0200
Local: Thurs, Jul 5 2012 1:22 am
Subject: Re: Running Pyramid with Gunicorn as non root user

Hi Mark,

So probably your user www-data can not find the pyramid.config module.
Try to import the module as user www-data.

Could it be for any reason, that your user www-data either has wrong environment variables set or has no read access to this module?

Kind regards
Cornelius

Am 05.07.2012 um 05:32 schrieb Mark Huang <zhengha...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Huang  
View profile  
 More options Jul 5 2012, 1:57 am
From: Mark Huang <zhengha...@gmail.com>
Date: Wed, 4 Jul 2012 22:57:22 -0700 (PDT)
Local: Thurs, Jul 5 2012 1:57 am
Subject: Re: Running Pyramid with Gunicorn as non root user

Sorry for a noob question:  "How do I import the module as user www-data
when the user doesn't even have shell access?"  Does this mean I have to
give this user a shell like /bin/bash?

"Could it be for any reason, that your user www-data either has wrong
environment variables set or has no read access to this module?"  Because I
am running the virtual environment as the root user, does this mean that
when I start gunicorn paster, the www-data user is unable to access the
modules in the virtual environment site-packages?  Currently the virtual
environment, being created by the root user, has root:root permissions.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Forkel  
View profile  
 More options Jul 5 2012, 2:30 am
From: Robert Forkel <xrotw...@googlemail.com>
Date: Thu, 5 Jul 2012 08:30:05 +0200
Local: Thurs, Jul 5 2012 2:30 am
Subject: Re: Running Pyramid with Gunicorn as non root user
sudo -u www-data python -c "import logging; print dir(logging)"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Forkel  
View profile  
 More options Jul 5 2012, 2:32 am
From: Robert Forkel <xrotw...@googlemail.com>
Date: Thu, 5 Jul 2012 08:32:16 +0200
Local: Thurs, Jul 5 2012 2:32 am
Subject: Re: Running Pyramid with Gunicorn as non root user
If gunicorn is installed in the environment, using the full path
/path/to/virtualenv/bin/gunicorn should be enough to "activate" the
virtualenv, thus making the packages available.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Randall Leeds  
View profile  
 More options Jul 7 2012, 12:54 pm
From: Randall Leeds <randall.le...@gmail.com>
Date: Sat, 7 Jul 2012 09:54:09 -0700
Local: Sat, Jul 7 2012 12:54 pm
Subject: Re: Running Pyramid with Gunicorn as non root user

On Jul 4, 2012 11:32 PM, "Robert Forkel" <xrotw...@googlemail.com> wrote:

> If gunicorn is installed in the environment, using the full path
> /path/to/virtualenv/bin/gunicorn should be enough to "activate" the
> virtualenv, thus making the packages available.

I suspect Robert is right. Is gunicorn is installed outside the virtualenv?

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
> >> line 320, in _loadconfig
> >>   File

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
> >> line 454, in get_context
> >>   File

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
> >> line 476, in _context_from_use
> >>   File

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
> >> line 406, in get_context
> >>   File

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
> >> line 296, in loadcontext
> >>   File

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
> >> line 328, in _loadegg
> >>   File

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
> >> line 620, in get_context
> >>   File

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/PasteDeploy-1.5.0 -py2.7.egg/paste/deploy/loadwsgi.py",
> >> line 646, in find_egg_entry_point
> >>   File

"/root/.virtualenvs/rhino_env/lib/python2.7/site-packages/setuptools-0.6c11 -py2.7.egg/pkg_resources.py",

"pylons-discuss" group.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to

pylons-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at

http://groups.google.com/group/pylons-discuss?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Huang  
View profile  
 More options Jul 8 2012, 11:15 pm
From: Mark Huang <zhengha...@gmail.com>
Date: Sun, 8 Jul 2012 20:15:13 -0700 (PDT)
Local: Sun, Jul 8 2012 11:15 pm
Subject: Re: Running Pyramid with Gunicorn as non root user

Gunicorn in the setup.py of my pyramid app.  So after entering the
virtualenv using virtualenvwrapper:

        workon my_env

I do a python setup.py develop.

Won't this add gunicorn to my virtual environment?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Randall Leeds  
View profile  
 More options Jul 10 2012, 9:26 pm
From: Randall Leeds <randall.le...@gmail.com>
Date: Tue, 10 Jul 2012 18:26:28 -0700
Local: Tues, Jul 10 2012 9:26 pm
Subject: Re: Running Pyramid with Gunicorn as non root user

On Wed, Jul 4, 2012 at 10:57 PM, Mark Huang <zhengha...@gmail.com> wrote:
> Sorry for a noob question:  "How do I import the module as user www-data
> when the user doesn't even have shell access?"  Does this mean I have to
> give this user a shell like /bin/bash?

> "Could it be for any reason, that your user www-data either has wrong
> environment variables set or has no read access to this module?"  Because I
> am running the virtual environment as the root user, does this mean that
> when I start gunicorn paster, the www-data user is unable to access the
> modules in the virtual environment site-packages?  Currently the virtual
> environment, being created by the root user, has root:root permissions.

just saw this. You should be sure the virtualenv is readable by www-data.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »