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
31062dd6
Commit
31062dd6
authored
Apr 05, 2016
by
Benny Ng
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #725 from tpng/reload-validate-caddyfile
revert to old Caddyfile on failed in-process restart
parents
28e0bfbb
b952fd8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
caddy/restart.go
caddy/restart.go
+10
-0
caddy/restart_windows.go
caddy/restart_windows.go
+9
-2
No files found.
caddy/restart.go
View file @
31062dd6
...
...
@@ -182,8 +182,18 @@ func restartInProc(newCaddyfile Input) error {
return
err
}
caddyfileMu
.
Lock
()
oldCaddyfile
:=
caddyfile
caddyfileMu
.
Unlock
()
err
=
Start
(
newCaddyfile
)
if
err
!=
nil
{
// revert to old Caddyfile
if
oldErr
:=
Start
(
oldCaddyfile
);
oldErr
!=
nil
{
log
.
Printf
(
"[ERROR] Restart: in-process restart failed and cannot revert to old Caddyfile: %v"
,
oldErr
)
}
else
{
wg
.
Done
()
// take down our barrier
}
return
err
}
...
...
caddy/restart_windows.go
View file @
31062dd6
...
...
@@ -7,11 +7,12 @@ import "log"
func
Restart
(
newCaddyfile
Input
)
error
{
log
.
Println
(
"[INFO] Restarting"
)
caddyfileMu
.
Lock
()
oldCaddyfile
:=
caddyfile
if
newCaddyfile
==
nil
{
caddyfileMu
.
Lock
()
newCaddyfile
=
caddyfile
caddyfileMu
.
Unlock
()
}
caddyfileMu
.
Unlock
()
wg
.
Add
(
1
)
// barrier so Wait() doesn't unblock
...
...
@@ -22,6 +23,12 @@ func Restart(newCaddyfile Input) error {
err
=
Start
(
newCaddyfile
)
if
err
!=
nil
{
// revert to old Caddyfile
if
oldErr
:=
Start
(
oldCaddyfile
);
oldErr
!=
nil
{
log
.
Printf
(
"[ERROR] Restart: in-process restart failed and cannot revert to old Caddyfile: %v"
,
oldErr
)
}
else
{
wg
.
Done
()
// take down our barrier
}
return
err
}
...
...
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