Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libapp-daemon-perl
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Debian Perl Group
M
modules
packages
libapp-daemon-perl
Commits
28d6d8c9
Commit
28d6d8c9
authored
Jul 20, 2011
by
Salvatore Bonaccorso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* New upstream release
* debian/copyright: Update copyright for upstream files.
parent
7ff91dac
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
44 deletions
+75
-44
Changes
Changes
+6
-0
Daemon.pm
Daemon.pm
+36
-24
META.yml
META.yml
+2
-2
README
README
+23
-17
debian/changelog
debian/changelog
+7
-0
debian/copyright
debian/copyright
+1
-1
No files found.
Changes
View file @
28d6d8c9
Revision history for Perl extension App::Daemon.
0.13 (07/19/2011)
(ms) [rt.cpan.org #69561] default log and pid files are now in the
current directory, not in /tmp by default because of security
concerns.
(ms) [rt.cpan.org #69561] not setting umask anymore
0.12 (07/18/2011)
(ms) 'status' now doesn't write to the logfile (suggested by Brian Pitts)
(ms) 'stop' now verifies if the process is still up, and retries
...
...
Daemon.pm
View file @
28d6d8c9
...
...
@@ -2,7 +2,7 @@ package App::Daemon;
use
strict
;
use
warnings
;
our
$VERSION
=
'
0.1
2
';
our
$VERSION
=
'
0.1
3
';
use
Getopt::
Std
;
use
Pod::
Usage
;
...
...
@@ -24,10 +24,13 @@ use constant LSB_UNKNOWN => 4;
use
constant
ALREADY_RUNNING
=>
150
;
our
(
$pidfile
,
$logfile
,
$l4p_conf
,
$as_user
,
$background
,
$loglevel
,
$action
,
$appname
);
$loglevel
,
$action
,
$appname
,
$default_pid_dir
,
$default_log_dir
);
$action
=
"";
$appname
=
appname
();
$default_pid_dir
=
"
.
";
$default_log_dir
=
"
.
";
our
$kill_retries
=
3
;
our
$kill_sig
=
SIGTERM
;
# maps to 15 via POSIX.pm
...
...
@@ -43,14 +46,14 @@ sub cmd_line_parse {
$pidfile
=
$_pidfile
;
}
else
{
$pidfile
||=
(
'
/tmp/
'
.
$appname
.
"
.pid
"
);
$pidfile
||=
(
"
$default_pid_dir
/
"
.
$appname
.
"
.pid
"
);
}
if
(
my
$_logfile
=
find_option
('
-l
',
1
))
{
$logfile
=
$_logfile
;
}
else
{
$logfile
||=
(
'
/tmp/
'
.
$appname
.
"
.log
"
);
$logfile
||=
(
"
$default_log_dir
/
"
.
$appname
.
"
.log
"
);
}
if
(
my
$_l4p_conf
=
find_option
('
-l4p
',
1
))
{
...
...
@@ -100,6 +103,8 @@ sub cmd_line_parse {
log4perl.appender.FileApp = Log::Log4perl::Appender::File
log4perl.appender.FileApp.filename = $logfile
log4perl.appender.FileApp.owner = $as_user
# this umask is only temporary
log4perl.appender.FileApp.umask = 0133
log4perl.appender.FileApp.layout = PatternLayout
log4perl.appender.FileApp.layout.ConversionPattern = %d %m%n
}
);
...
...
@@ -190,7 +195,8 @@ sub detach {
###########################################
my
(
$as_user
)
=
@_
;
umask
(
0
);
# newly created files have rw-r--r-- permissions by default
umask
(
0133
);
# Make sure the child isn't killed when the user closes the
# terminal session before the child detaches from the tty.
...
...
@@ -366,7 +372,8 @@ sub pid_file_write {
###########################################
my
(
$pid
)
=
@_
;
open
FILE
,
"
+>
$pidfile
"
or
LOGDIE
"
Cannot open pidfile
$pidfile
";
sysopen
FILE
,
$pidfile
,
O_RDWR
|
O_CREAT
,
0644
or
LOGDIE
"
Cannot open pidfile
$pidfile
";
flock
FILE
,
LOCK_EX
;
seek
(
FILE
,
0
,
0
);
print
FILE
"
$pid
\n
";
...
...
@@ -470,7 +477,7 @@ shows with the 'status' command if an instance is already running
and which PID it has:
./my-app status
Pid file:
/tmp
/tt.pid
Pid file:
.
/tt.pid
Pid in file: 14914
Running: no
Name match: 0
...
...
@@ -489,9 +496,18 @@ will start up the daemon. "start" itself is optional, as this is the
default action,
$ ./my-app
$
will also run the 'start' action. If the -X option is given, the program
is run in foreground mode for testing purposes.
will also run the 'start' action. By default, it will create a pid file
and a log file in the current directory
(named C<my-app.pid> and C<my-app.log>. To change these locations, see
the C<-l> and C<-p> options.
If the -X option is given, the program
is running in foreground mode for testing purposes:
$ ./my-app -X
...
=item stop
...
...
@@ -510,9 +526,9 @@ string like "SIGINT".
=item status
will print out diagnostics on what the status of the daemon is. Typically,
the output look like this:
the output look
s
like this:
Pid file:
/tmp
/tt.pid
Pid file:
.
/tt.pid
Pid in file: 15562
Running: yes
Name match: 1
...
...
@@ -532,7 +548,7 @@ C<test.pl>, it will match lines like "perl -w test.pl" or
If the process is no longer running, the status output might look like
this instead:
Pid file:
/tmp
/tt.pid
Pid file:
.
/tt.pid
Pid in file: 14914
Running: no
Name match: 0
...
...
@@ -570,7 +586,9 @@ Foreground mode. Log messages go to the screen.
=item -l logfile
Logfile to send Log4perl messages to in background mode. Defaults
to C</tmp/[appname].log>.
to C<./[appname].log>. Note that having a logfile in the current directory
doesn't make sense except for testing environments, make sure to set this
to somewhere within C</var/log> for production use.
=item -u as_user
...
...
@@ -584,7 +602,11 @@ will be ignored.
=item -p pidfile
Where to save the pid of the started process.
Defaults to C</tmp/[appname].pid>.
Defaults to C<./[appname].pid>.
Note that
having a pidfile in the current directory
doesn't make sense except for testing environments, make sure to set this
to somewhere within C</var/run> for production use.
=item -v
...
...
@@ -677,16 +699,6 @@ shell prompt immediately.
2011, Mike Schilli <cpan@perlmeister.com>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2008 by Mike Schilli
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.5 or,
at your option, any later version of Perl 5 you may have available.
=cut
=head1 LICENSE
Copyright 2011 by Mike Schilli, all rights reserved.
...
...
META.yml
View file @
28d6d8c9
---
#YAML:1.0
name
:
App-Daemon
version
:
0.1
2
version
:
0.1
3
abstract
:
Start an Application as a Daemon
author
:
-
Mike Schilli <m@perlmeister.com>
...
...
@@ -26,7 +26,7 @@ no_index:
directory
:
-
t
-
inc
generated_by
:
ExtUtils::MakeMaker version
6.5
6
generated_by
:
ExtUtils::MakeMaker version 6.5
5_02
meta-spec
:
url
:
http://module-build.sourceforge.net/META-spec-v1.4.html
version
:
1.4
README
View file @
28d6d8c9
######################################################################
App::Daemon 0.1
2
App::Daemon 0.1
3
######################################################################
NAME
...
...
@@ -55,7 +55,7 @@ DESCRIPTION
and which PID it has:
./my-app status
Pid file:
/tmp
/tt.pid
Pid file:
.
/tt.pid
Pid in file: 14914
Running: no
Name match: 0
...
...
@@ -68,9 +68,18 @@ DESCRIPTION
default action,
$ ./my-app
will also run the 'start' action. If the -X option is given, the
program is run in foreground mode for testing purposes.
$
will also run the 'start' action. By default, it will create a pid
file and a log file in the current directory (named "my-app.pid" and
"my-app.log". To change these locations, see the "-l" and "-p"
options.
If the -X option is given, the program is running in foreground mode
for testing purposes:
$ ./my-app -X
...
stop
will find the daemon's PID in the pidfile and send it a SIGTERM
...
...
@@ -88,9 +97,9 @@ DESCRIPTION
status
will print out diagnostics on what the status of the daemon is.
Typically, the output look like this:
Typically, the output look
s
like this:
Pid file:
/tmp
/tt.pid
Pid file:
.
/tt.pid
Pid in file: 15562
Running: yes
Name match: 1
...
...
@@ -110,7 +119,7 @@ DESCRIPTION
If the process is no longer running, the status output might look
like this instead:
Pid file:
/tmp
/tt.pid
Pid file:
.
/tt.pid
Pid in file: 14914
Running: no
Name match: 0
...
...
@@ -140,7 +149,9 @@ DESCRIPTION
-l logfile
Logfile to send Log4perl messages to in background mode. Defaults to
"/tmp/[appname].log".
"./[appname].log". Note that having a logfile in the current
directory doesn't make sense except for testing environments, make
sure to set this to somewhere within "/var/log" for production use.
-u as_user
User to run as if started as root. Defaults to 'nobody'.
...
...
@@ -151,7 +162,9 @@ DESCRIPTION
-p pidfile
Where to save the pid of the started process. Defaults to
"/tmp/[appname].pid".
"./[appname].pid". Note that having a pidfile in the current
directory doesn't make sense except for testing environments, make
sure to set this to somewhere within "/var/run" for production use.
-v Increase default Log4perl verbosity from $INFO to $DEBUG. Note that
this option will be ignored if Log4perl is initialized independently
...
...
@@ -234,13 +247,6 @@ DESCRIPTION
AUTHOR
2011, Mike Schilli <cpan@perlmeister.com>
COPYRIGHT AND LICENSE
Copyright (C) 2008 by Mike Schilli
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8.5 or, at
your option, any later version of Perl 5 you may have available.
LICENSE
Copyright 2011 by Mike Schilli, all rights reserved. This program is
...
...
debian/changelog
View file @
28d6d8c9
libapp-daemon-perl (0.13-1) UNRELEASED; urgency=low
* New upstream release
* debian/copyright: Update copyright for upstream files.
-- Salvatore Bonaccorso <carnil@debian.org> Wed, 20 Jul 2011 09:48:35 +0200
libapp-daemon-perl (0.12-1) unstable; urgency=low
* New upstream release
...
...
debian/copyright
View file @
28d6d8c9
...
...
@@ -4,7 +4,7 @@ Source: http://search.cpan.org/dist/App-Daemon/
Name: App-Daemon
Files: *
Copyright: 20
08-20
11, Mike Schilli <m@perlmeister.com>
Copyright: 2011, Mike Schilli <m@perlmeister.com>
License: Artistic or GPL-1+
Files: debian/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment