Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
poolmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Patrick Cernko
poolmon
Commits
e4c22c27
Commit
e4c22c27
authored
8 years ago
by
Brandon Davidson
Browse files
Options
Downloads
Plain Diff
Merge pull request #4 from mikalsande/master
Removed handling of __DIE__ signal.
parents
a5588655
89d8b4da
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
poolmon
+24
-4
24 additions, 4 deletions
poolmon
with
24 additions
and
4 deletions
poolmon
+
24
−
4
View file @
e4c22c27
...
...
@@ -39,6 +39,7 @@ my $NOFORK = 0;
my
$TIMEOUT
=
5
;
my
$INTERVAL
=
30
;
my
$PIDOPEN
=
0
;
my
$ORIGPID
=
0
;
my
$PIDFILE
=
'
/var/run/poolmon.pid
';
my
$LOGFILE
=
'
/var/log/poolmon.log
';
my
$DIRECTOR
=
'
/var/run/dovecot/director-admin
';
...
...
@@ -218,7 +219,10 @@ sub scan_port {
Timeout
=>
$TIMEOUT
);
$ret
=
eval
{
local
$SIG
{
ALRM
}
=
sub
{
die
"
Timeout
\n
"
};
local
$SIG
{
ALRM
}
=
sub
{
$DEBUG
&&
write_log
("
Timeout
");
die
"
Timeout
\n
";
};
alarm
$TIMEOUT
;
if
(
$sock
){
if
(
$prot
eq
'
IMAP
'){
...
...
@@ -372,10 +376,11 @@ sub check_pidfile {
# Remove the pidfile and exit
sub
remove_pidfile
{
return
unless
$PIDOPEN
;
return
unless
$PIDOPEN
;
if
(
$$
==
$ORIGPID
)
{
write_log
('
Shutting down
');
unlink
(
$PIDFILE
);
exit
(
0
);
}
}
sub
opt_weights
{
...
...
@@ -470,7 +475,18 @@ sub daemonize {
# Open pidfile and register cleanup handlers
# Do this before forking so we can abort on failure
$PIDOPEN
=
open
(
$FH
,
"
>
$PIDFILE
")
or
die
"
Can't open pidfile
$PIDFILE
: $!
";
$SIG
{'
INT
'}
=
$SIG
{'
QUIT
'}
=
$SIG
{'
TERM
'}
=
$SIG
{'
__DIE__
'}
=
\
&remove_pidfile
;
$SIG
{'
INT
'}
=
sub
{
$DEBUG
&&
write_log
("
Caught signal INT
");
remove_pidfile
();
};
$SIG
{'
QUIT
'}
=
sub
{
$DEBUG
&&
write_log
("
Caught signal QUIT
");
remove_pidfile
();
};
$SIG
{'
TERM
'}
=
sub
{
$DEBUG
&&
write_log
("
Caught signal TERM
");
remove_pidfile
();
};
# Disconnect from terminal and session
chdir
('
/
')
or
die
"
Can't chdir to /: $!
";
...
...
@@ -486,6 +502,7 @@ sub daemonize {
write_log
("
Forked to background as PID $$
");
print
$FH
"
$$
\n
";
close
(
$FH
);
$ORIGPID
=
$$
;
# Reopen logfiles and reparse weights on HUP
$SIG
{'
HUP
'}
=
sub
{
...
...
@@ -497,3 +514,6 @@ sub daemonize {
}
}
END
{
remove_pidfile
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment