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
Łukasz Nowak
caddy
Commits
70d6caf9
Commit
70d6caf9
authored
May 06, 2015
by
Abiola Ibrahim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server: read -conf flag before reading stdin config file
parent
47717fee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
15 deletions
+13
-15
main.go
main.go
+13
-15
No files found.
main.go
View file @
70d6caf9
...
@@ -24,7 +24,6 @@ var (
...
@@ -24,7 +24,6 @@ var (
http2
bool
// TODO: temporary flag until http2 is standard
http2
bool
// TODO: temporary flag until http2 is standard
quiet
bool
quiet
bool
cpu
string
cpu
string
confBody
[]
byte
// configuration data to use, piped from stdin
)
)
func
init
()
{
func
init
()
{
...
@@ -39,18 +38,6 @@ func init() {
...
@@ -39,18 +38,6 @@ func init() {
config
.
AppName
=
"Caddy"
config
.
AppName
=
"Caddy"
config
.
AppVersion
=
"0.6.0"
config
.
AppVersion
=
"0.6.0"
// Load piped configuration data, if any
fi
,
err
:=
os
.
Stdin
.
Stat
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
if
fi
.
Mode
()
&
os
.
ModeCharDevice
==
0
{
confBody
,
err
=
ioutil
.
ReadAll
(
os
.
Stdin
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
}
}
}
func
main
()
{
func
main
()
{
...
@@ -117,9 +104,20 @@ func loadConfigs() ([]server.Config, error) {
...
@@ -117,9 +104,20 @@ func loadConfigs() ([]server.Config, error) {
}
}
// stdin
// 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
{
confBody
,
err
:=
ioutil
.
ReadAll
(
os
.
Stdin
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
if
len
(
confBody
)
>
0
{
if
len
(
confBody
)
>
0
{
return
config
.
Load
(
"stdin"
,
bytes
.
NewReader
(
confBody
))
return
config
.
Load
(
"stdin"
,
bytes
.
NewReader
(
confBody
))
}
}
}
// Caddyfile
// Caddyfile
file
,
err
:=
os
.
Open
(
config
.
DefaultConfigFile
)
file
,
err
:=
os
.
Open
(
config
.
DefaultConfigFile
)
...
...
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