Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
106d62b0
Commit
106d62b0
authored
Jan 26, 2018
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sigtrap: Fix log messages, and ignore SIGHUP (#1993)
parent
a76222f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
sigtrap_posix.go
sigtrap_posix.go
+12
-11
No files found.
sigtrap_posix.go
View file @
106d62b0
...
...
@@ -25,8 +25,6 @@ import (
// trapSignalsPosix captures POSIX-only signals.
func
trapSignalsPosix
()
{
signalToString
:=
map
[
os
.
Signal
]
string
{
syscall
.
SIGHUP
:
"SIGHUP"
,
syscall
.
SIGUSR1
:
"SIGUSR1"
}
go
func
()
{
sigchan
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
sigchan
,
syscall
.
SIGTERM
,
syscall
.
SIGHUP
,
syscall
.
SIGQUIT
,
syscall
.
SIGUSR1
,
syscall
.
SIGUSR2
)
...
...
@@ -34,15 +32,15 @@ func trapSignalsPosix() {
for
sig
:=
range
sigchan
{
switch
sig
{
case
syscall
.
SIGQUIT
:
log
.
Println
(
"[INFO] SIGQUIT:
Terminating process
"
)
log
.
Println
(
"[INFO] SIGQUIT:
Quitting process immediately
"
)
if
PidFile
!=
""
{
os
.
Remove
(
PidFile
)
}
os
.
Exit
(
0
)
case
syscall
.
SIGTERM
:
log
.
Println
(
"[INFO] SIGTERM: Shutting down"
)
exitCode
:=
executeShutdownCallbacks
(
signalToString
[
sig
]
)
log
.
Println
(
"[INFO] SIGTERM: Shutting down
servers then terminating
"
)
exitCode
:=
executeShutdownCallbacks
(
"SIGTERM"
)
err
:=
Stop
()
if
err
!=
nil
{
log
.
Printf
(
"[ERROR] SIGTERM stop: %v"
,
err
)
...
...
@@ -53,25 +51,25 @@ func trapSignalsPosix() {
}
os
.
Exit
(
exitCode
)
case
syscall
.
SIGUSR1
,
syscall
.
SIGHUP
:
log
.
Print
f
(
"[INFO] %s: Reloading"
,
signalToString
[
sig
]
)
case
syscall
.
SIGUSR1
:
log
.
Print
ln
(
"[INFO] SIGUSR1: Reloading"
)
// Start with the existing Caddyfile
caddyfileToUse
,
inst
,
err
:=
getCurrentCaddyfile
()
if
err
!=
nil
{
log
.
Printf
(
"[ERROR]
%s: %v"
,
signalToString
[
sig
]
,
err
)
log
.
Printf
(
"[ERROR]
SIGUSR1: %v"
,
err
)
continue
}
if
loaderUsed
.
loader
==
nil
{
// This also should never happen
log
.
Print
f
(
"[ERROR] %s: no Caddyfile loader with which to reload Caddyfile"
,
signalToString
[
sig
]
)
log
.
Print
ln
(
"[ERROR] SIGUSR1: no Caddyfile loader with which to reload Caddyfile"
)
continue
}
// Load the updated Caddyfile
newCaddyfile
,
err
:=
loaderUsed
.
loader
.
Load
(
inst
.
serverType
)
if
err
!=
nil
{
log
.
Printf
(
"[ERROR]
%s: loading updated Caddyfile: %v"
,
signalToString
[
sig
]
,
err
)
log
.
Printf
(
"[ERROR]
SIGUSR1: loading updated Caddyfile: %v"
,
err
)
continue
}
if
newCaddyfile
!=
nil
{
...
...
@@ -81,7 +79,7 @@ func trapSignalsPosix() {
// Kick off the restart; our work is done
_
,
err
=
inst
.
Restart
(
caddyfileToUse
)
if
err
!=
nil
{
log
.
Printf
(
"[ERROR]
%s: %v"
,
signalToString
[
sig
]
,
err
)
log
.
Printf
(
"[ERROR]
SIGUSR1: %v"
,
err
)
}
case
syscall
.
SIGUSR2
:
...
...
@@ -89,6 +87,9 @@ func trapSignalsPosix() {
if
err
:=
Upgrade
();
err
!=
nil
{
log
.
Printf
(
"[ERROR] SIGUSR2: upgrading: %v"
,
err
)
}
case
syscall
.
SIGHUP
:
// ignore; this signal is sometimes sent outside of the user's control
}
}
}()
...
...
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