Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

On Debian, I have written a simple init script for a Pyramid application using pserve. I am not 100% sure that it is complete/correct, but it works for now:

DAEMON="/home/project/.virtualenvs/project/bin/pserve /home/project/production.ini"

case "$1" in
    echo "$1 project app server: "
    cd $CWD
    $DAEMON $1 --pid-file=$PIDFILE --user=$USER --group=$GROUP --log-file=$LOGFILE
    if [ "$RETVAL" -eq "0" ]; then
        echo "Success"
    echo "Usage: /etc/init.d/project {start|stop|restart|status}"
    exit 1

exit 0

When I log in as root, I can run the following without issue:

~# service project start
start project app server: 
Changing user to project:project (200:1001)
Entering daemon mode

I put the following into my Puppet configuration for the machine:

  file { '/etc/init.d/project':
    ensure => present,
    group => 'root',
    mode => 'a=rx,u+w',
    owner => 'root',
    source => 'puppet:///modules/project/project.init',

  service { 'project':
    enable => true,
    ensure => running,
    require => File['/etc/init.d/project'],

However, when I run puppet agent --test, the service is not left in a running state. When I look in the project's log file, I see the following:

  File "/home/project/.virtualenvs/project/lib/python2.7/site-packages/project-0.0-py2.7.egg/project/model/", line 1, in <module>
    from base import Base, DBSession, initialize_sql
  File "/home/project/.virtualenvs/project/lib/python2.7/site-packages/project-0.0-py2.7.egg/project/model/", line 1, in <module>
    from sqlalchemy import Column, engine_from_config
  File "build/bdist.linux-x86_64/egg/sqlalchemy/", line 52, in <module>

  File "build/bdist.linux-x86_64/egg/sqlalchemy/", line 33, in <module>
    except NameError:
  File "build/bdist.linux-x86_64/egg/sqlalchemy/", line 98, in <module>
  File "build/bdist.linux-x86_64/egg/sqlalchemy/", line 7, in <module>
  File "build/bdist.linux-x86_64/egg/sqlalchemy/", line 4, in __bootstrap__
  File "build/bdist.linux-i686/egg/", line 882, in resource_filename
  File "build/bdist.linux-i686/egg/", line 1351, in get_resource_filename
  File "build/bdist.linux-i686/egg/", line 1373, in _extract_resource
  File "build/bdist.linux-i686/egg/", line 962, in get_cache_path
  File "build/bdist.linux-i686/egg/", line 928, in extraction_error
pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg

  [Errno 13] Permission denied: '/root/.python-eggs'

The Python egg cache directory is currently set to:


As I noted, logging in as root and starting it seems to work fine. I would imagine that Puppet does something similar. What's the missing piece?

share|improve this question

1 Answer 1

The problem is your python egg cache, its trying to write to the root directory. Add the following to your script.

export PYTHON_EGG_CACHE=/var/tmp
share|improve this answer
Thanks, that seems to fix it, I guess. Any idea on why it's broken in the first place though? It seems strange that I can run it by hand but not through puppet. – dave mankoff Oct 31 '12 at 13:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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