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
74d4fd3c
Commit
74d4fd3c
authored
Oct 31, 2017
by
Arthur Silva
Committed by
Matt Holt
Oct 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve error checking (#1938)
parent
ac1f3bfa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
12 deletions
+39
-12
assets_test.go
assets_test.go
+8
-2
caddy.go
caddy.go
+23
-8
upgrade.go
upgrade.go
+8
-2
No files found.
assets_test.go
View file @
74d4fd3c
...
...
@@ -25,9 +25,15 @@ func TestAssetsPath(t *testing.T) {
t
.
Errorf
(
"Expected path to be a .caddy folder, got: %v"
,
actual
)
}
os
.
Setenv
(
"CADDYPATH"
,
"testpath"
)
err
:=
os
.
Setenv
(
"CADDYPATH"
,
"testpath"
)
if
err
!=
nil
{
t
.
Error
(
"Could not set CADDYPATH"
)
}
if
actual
,
expected
:=
AssetsPath
(),
"testpath"
;
actual
!=
expected
{
t
.
Errorf
(
"Expected path to be %v, got: %v"
,
expected
,
actual
)
}
os
.
Setenv
(
"CADDYPATH"
,
""
)
err
=
os
.
Setenv
(
"CADDYPATH"
,
""
)
if
err
!=
nil
{
t
.
Error
(
"Could not set CADDYPATH"
)
}
}
caddy.go
View file @
74d4fd3c
...
...
@@ -206,12 +206,15 @@ func (i *Instance) Restart(newCaddyfile Input) (*Instance, error) {
// success! stop the old instance
for
_
,
shutdownFunc
:=
range
i
.
onShutdown
{
err
:
=
shutdownFunc
()
err
=
shutdownFunc
()
if
err
!=
nil
{
return
i
,
err
}
}
i
.
Stop
()
err
=
i
.
Stop
()
if
err
!=
nil
{
return
i
,
err
}
// Execute instantiation events
EmitEvent
(
InstanceStartupEvent
,
newInst
)
...
...
@@ -483,14 +486,14 @@ func startWithListenerFds(cdyfile Input, inst *Instance, restartFds map[string]r
if
!
IsUpgrade
()
&&
restartFds
==
nil
{
// first startup means not a restart or upgrade
for
_
,
firstStartupFunc
:=
range
inst
.
onFirstStartup
{
err
:
=
firstStartupFunc
()
err
=
firstStartupFunc
()
if
err
!=
nil
{
return
err
}
}
}
for
_
,
startupFunc
:=
range
inst
.
onStartup
{
err
:
=
startupFunc
()
err
=
startupFunc
()
if
err
!=
nil
{
return
err
}
...
...
@@ -653,7 +656,10 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res
if
fdIndex
,
ok
:=
loadedGob
.
ListenerFds
[
"tcp"
+
addr
];
ok
{
file
:=
os
.
NewFile
(
fdIndex
,
""
)
ln
,
err
=
net
.
FileListener
(
file
)
file
.
Close
()
if
err
!=
nil
{
return
err
}
err
=
file
.
Close
()
if
err
!=
nil
{
return
err
}
...
...
@@ -661,7 +667,10 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res
if
fdIndex
,
ok
:=
loadedGob
.
ListenerFds
[
"udp"
+
addr
];
ok
{
file
:=
os
.
NewFile
(
fdIndex
,
""
)
pc
,
err
=
net
.
FilePacketConn
(
file
)
file
.
Close
()
if
err
!=
nil
{
return
err
}
err
=
file
.
Close
()
if
err
!=
nil
{
return
err
}
...
...
@@ -684,7 +693,10 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res
if
err
!=
nil
{
return
err
}
file
.
Close
()
err
=
file
.
Close
()
if
err
!=
nil
{
return
err
}
}
// packetconn
if
old
.
packet
!=
nil
{
...
...
@@ -696,7 +708,10 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res
if
err
!=
nil
{
return
err
}
file
.
Close
()
err
=
file
.
Close
()
if
err
!=
nil
{
return
err
}
}
}
}
...
...
upgrade.go
View file @
74d4fd3c
...
...
@@ -136,7 +136,10 @@ func Upgrade() error {
// immediately close our dup'ed fds and the write end of our signal pipe
for
_
,
f
:=
range
extraFiles
{
f
.
Close
()
err
=
f
.
Close
()
if
err
!=
nil
{
return
err
}
}
// feed Caddyfile to the child
...
...
@@ -144,7 +147,10 @@ func Upgrade() error {
if
err
!=
nil
{
return
err
}
wpipe
.
Close
()
err
=
wpipe
.
Close
()
if
err
!=
nil
{
return
err
}
// determine whether child startup succeeded
answer
,
readErr
:=
ioutil
.
ReadAll
(
sigrpipe
)
...
...
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