MToken
view release on metacpan or search on metacpan
lib/MToken.pm view on Meta::CPAN
} else { #~/.local/share/mtoken/www
$self->datadir(File::Spec->catdir(File::HomeDir->my_data(), PROJECTNAMEL, "www"));
}
unless (-e $self->datadir) {
unless (preparedir($self->datadir)) {
$self->error(sprintf("Can't prepare directory %s", $self->datadir));
return 0;
}
}
# Set permisions (GID and UID) for work directory
chown($uid, $gid, $self->datadir) if IS_ROOT && File::stat::stat($self->datadir)->uid != $uid;
}
# Prepare tempdir
$self->tempdir(File::Spec->catdir(File::Spec->tmpdir(), PROJECTNAMEL));
unless (preparedir( $self->tempdir, 0777 )) {
$self->error(sprintf("Can't prepare temp directory: %s", $self->tempdir));
return 0;
}
chown($uid, $gid, $self->tempdir) if IS_ROOT && File::stat::stat($self->tempdir)->uid != $uid;
$self->debug(sprintf("Temp dir: %s", $self->tempdir));
# Prepare log directory
if (IS_ROOT) {
my $logdir = $self->logdir;
unless (preparedir( $logdir, 0777 )) {
$self->error(sprintf("Can't prepare log directory: %s", $logdir));
return 0;
}
# Set permisions (GID and UID) for log directory
chown($uid, $gid, $logdir) if File::stat::stat($logdir)->uid != $uid;
$self->debug(sprintf("Log dir: %s", $self->logdir));
} else {
$self->logfile(File::Spec->catfile($self->tempdir(), sprintf("%s.log", PROJECTNAMEL)));
$self->debug(sprintf("Log file: %s", $self->logfile));
}
# Prepare pid directory and file
my $piddir = IS_ROOT ? File::Spec->catdir( rundir(), PROJECTNAMEL) : $self->tempdir();
my $pidfile = File::Spec->catfile($piddir, sprintf("%s.pid", PROJECTNAMEL));
unless (preparedir($piddir)) {
$self->error(sprintf("Can't prepare pid directory: %s", $piddir));
return 0;
}
# Set permisions (GID and UID) for pid directory
chown($uid, $gid, $piddir) if IS_ROOT && File::stat::stat($piddir)->uid != $uid;
$self->debug(sprintf("Pid file: %s", $pidfile));
# Hypnotoad variables
my $upgrade = 0;
my $reload = 0;
my $upgrade_timeout = UPGRADE_TIMEOUT;
# Mojolicious Application
my $app = MToken::Server->new(ctk => $self);
$app->attr(ctk => sub { $self }); # has ctk => sub { CTKx->instance->ctk };
( run in 0.467 second using v1.01-cache-2.11-cpan-5511b514fd6 )