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
32e63e6b
Commit
32e63e6b
authored
Apr 06, 2016
by
Benny Ng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract restartInProc to its own file
parent
86ccafbe
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
53 deletions
+35
-53
caddy/restart.go
caddy/restart.go
+0
-29
caddy/restart_windows.go
caddy/restart_windows.go
+3
-24
caddy/restartinproc.go
caddy/restartinproc.go
+32
-0
No files found.
caddy/restart.go
View file @
32e63e6b
...
...
@@ -172,32 +172,3 @@ 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
}
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
}
wg
.
Done
()
// take down our barrier
return
nil
}
caddy/restart_windows.go
View file @
32e63e6b
...
...
@@ -7,32 +7,11 @@ import "log"
func
Restart
(
newCaddyfile
Input
)
error
{
log
.
Println
(
"[INFO] Restarting"
)
caddyfileMu
.
Lock
()
oldCaddyfile
:=
caddyfile
if
newCaddyfile
==
nil
{
caddyfileMu
.
Lock
()
newCaddyfile
=
caddyfile
}
caddyfileMu
.
Unlock
()
wg
.
Add
(
1
)
// barrier so Wait() doesn't unblock
err
:=
Stop
()
if
err
!=
nil
{
return
err
}
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
}
wg
.
Done
()
// take down our barrier
return
nil
return
restartInProc
(
newCaddyfile
)
}
caddy/restartinproc.go
0 → 100644
View file @
32e63e6b
package
caddy
import
"log"
// 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
}
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
}
wg
.
Done
()
// take down our barrier
return
nil
}
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