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
260c023e
Commit
260c023e
authored
Mar 21, 2016
by
Benny Ng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add -restart=inproc flag for in process restart
parent
27f9b58c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
caddy/caddy.go
caddy/caddy.go
+5
-0
caddy/restart.go
caddy/restart.go
+27
-0
main.go
main.go
+1
-0
No files found.
caddy/caddy.go
View file @
260c023e
...
...
@@ -52,6 +52,11 @@ var (
// GracefulTimeout is the maximum duration of a graceful shutdown.
GracefulTimeout
time
.
Duration
// RestartMode is the mode used for restart,
// "inproc" will restart in process,
// otherwise default behavior is used (inproc on Windows, fork on Linux).
RestartMode
=
""
)
var
(
...
...
caddy/restart.go
View file @
260c023e
...
...
@@ -25,6 +25,10 @@ func init() {
// downtime if on a POSIX-compatible system, or forcefully if on
// Windows but with imperceptibly-short downtime.
//
// The behavior can be controlled by the RestartMode variable,
// where "inproc" will restart forcefully in process same as
// Windows on a POSIX-compatible system.
//
// The restarted application will use newCaddyfile as its input
// configuration. If newCaddyfile is nil, the current (existing)
// Caddyfile configuration will be used.
...
...
@@ -48,6 +52,10 @@ func Restart(newCaddyfile Input) error {
return
errors
.
New
(
"TLS preload: "
+
err
.
Error
())
}
if
RestartMode
==
"inproc"
{
return
restartInProc
(
newCaddyfile
)
}
if
len
(
os
.
Args
)
==
0
{
// this should never happen, but...
os
.
Args
=
[]
string
{
""
}
}
...
...
@@ -164,3 +172,22 @@ func getCertsForNewCaddyfile(newCaddyfile Input) error {
return
nil
}
// restartInProc restarts Caddy forcefully in process using newCaddyfile.
func
restartInProc
(
newCaddyfile
Input
)
error
{
wg
.
Add
(
1
)
// barrier so Wait() doesn't unblock
err
:=
Stop
()
if
err
!=
nil
{
return
err
}
err
=
Start
(
newCaddyfile
)
if
err
!=
nil
{
return
err
}
wg
.
Done
()
// take down our barrier
return
nil
}
main.go
View file @
260c023e
...
...
@@ -33,6 +33,7 @@ func init() {
flag
.
StringVar
(
&
caddy
.
PidFile
,
"pidfile"
,
""
,
"Path to write pid file"
)
flag
.
StringVar
(
&
caddy
.
Port
,
"port"
,
caddy
.
DefaultPort
,
"Default port"
)
flag
.
BoolVar
(
&
caddy
.
Quiet
,
"quiet"
,
false
,
"Quiet mode (no initialization output)"
)
flag
.
StringVar
(
&
caddy
.
RestartMode
,
"restart"
,
""
,
"Restart mode (inproc for in process restart)"
)
flag
.
StringVar
(
&
revoke
,
"revoke"
,
""
,
"Hostname for which to revoke the certificate"
)
flag
.
StringVar
(
&
caddy
.
Root
,
"root"
,
caddy
.
DefaultRoot
,
"Root path to default site"
)
flag
.
BoolVar
(
&
version
,
"version"
,
false
,
"Show version"
)
...
...
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