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
898896f9
Commit
898896f9
authored
May 06, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for stdin on Windows
parent
63ccc626
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
main.go
main.go
+7
-5
No files found.
main.go
View file @
898896f9
...
...
@@ -104,12 +104,13 @@ func loadConfigs() ([]server.Config, error) {
}
// stdin
// Load piped configuration data, if any
fi
,
err
:=
os
.
Stdin
.
Stat
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
if
err
==
nil
&&
fi
.
Mode
()
&
os
.
ModeCharDevice
==
0
{
// Note that a non-nil error is not a problem. Windows
// will not create a stdin if there is no pipe, which
// produces an error when calling Stat(). But Unix will
// make one either way, which is why we also check that
// bitmask.
confBody
,
err
:=
ioutil
.
ReadAll
(
os
.
Stdin
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
...
...
@@ -128,6 +129,7 @@ func loadConfigs() ([]server.Config, error) {
return
[]
server
.
Config
{},
err
}
defer
file
.
Close
()
return
config
.
Load
(
config
.
DefaultConfigFile
,
file
)
}
...
...
@@ -143,7 +145,7 @@ func arrangeBindings(allConfigs []server.Config) (map[string][]server.Config, er
for
_
,
conf
:=
range
allConfigs
{
addr
,
err
:=
net
.
ResolveTCPAddr
(
"tcp"
,
conf
.
Address
())
if
err
!=
nil
{
return
addresses
,
err
return
addresses
,
err
ors
.
New
(
"Could not serve "
+
conf
.
Address
()
+
" - "
+
err
.
Error
())
}
addresses
[
addr
.
String
()]
=
append
(
addresses
[
addr
.
String
()],
conf
)
}
...
...
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