write_pid() does not create the directory to contain it #23

karenetheridge opened this Issue Jun 14, 2012 · 7 comments


None yet
3 participants

karenetheridge commented Jun 14, 2012

Currently the pid directory must exist first; it would be polite to create it (using the proper non-root permissions) if it does not already exist.

BTW all this (and the creation/writing to the file itself) can all be simplified by using the interfaces in Path::Class::Dir and Path::Class::File.


karenetheridge commented Jun 15, 2012

This should be done after issue #16, as it will be easier to manage the permission issue (you don't have to worry about using the right uid/gid for creating the dir, as you will have already switched users/groups).


karenetheridge commented Jul 13, 2012

This is what I'm doing as a workaround for now, for a missing pid dir as well as to figure out the proper user:

my $USERNAME = 'foo';

my $uid = getpwnam($USERNAME)
    or warn "$USERNAME user not found; defaulting to " . getpwuid($<), "\n";
$uid //= $<;
my $user = getpwuid($uid);

my $base = -e 'dist.ini' && -d 'blib' && -e 'MYMETA.yml'
    ? '.'
    : (getpwnam($user))[7];

my $piddir = $base . '/pid';
if (!-d $piddir)
    mkdir $piddir;
    chown($uid, -1, $piddir) if $uid != $<;

symkat commented Sep 4, 2012

A new option resource_dir has been added. This directory will be created during do_start if it doesn't exist, and the owner will be set to the UID/GID permissions should drop to.

symkat closed this Sep 4, 2012


karenetheridge commented Sep 8, 2012

looks to be in commit 5ad22a2


karenetheridge commented Sep 8, 2012

Is this a user-facing config value? There is no POD for it.

What else could this dir be used for, other than a pid, as "resource dir" is a genericish name?

symkat reopened this Sep 10, 2012

jigso commented Feb 14, 2013

The commit 5ad22a2 works well, except the $self->_create_resource_dir in do_start is not at the right place : it should be before the write_pid, not after...


karenetheridge commented Apr 19, 2013

BTW this was finished up in #40

I wasn't sure if the resource_dir was intended to be just the pid dir or something else.. but it makes sense to always make the pid dir, whether or not resource_dir is also being referenced (therefore it can be used for something else, e.g. a log dir or for storing state files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment