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
bb6613d0
Commit
bb6613d0
authored
Oct 26, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: Fix SIGUSR1 so it actually reloads config
parent
821c0fab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
1 deletion
+28
-1
caddy/caddy.go
caddy/caddy.go
+4
-0
caddy/helpers.go
caddy/helpers.go
+4
-0
caddy/sigtrap_posix.go
caddy/sigtrap_posix.go
+18
-1
main.go
main.go
+2
-0
No files found.
caddy/caddy.go
View file @
bb6613d0
...
@@ -319,4 +319,8 @@ type Input interface {
...
@@ -319,4 +319,8 @@ type Input interface {
// Gets the path to the origin file
// Gets the path to the origin file
Path
()
string
Path
()
string
// IsFile returns true if the original input was a file on the file system
// that could be loaded again later if requested.
IsFile
()
bool
}
}
caddy/helpers.go
View file @
bb6613d0
...
@@ -58,6 +58,7 @@ func isRestart() bool {
...
@@ -58,6 +58,7 @@ func isRestart() bool {
type
CaddyfileInput
struct
{
type
CaddyfileInput
struct
{
Filepath
string
Filepath
string
Contents
[]
byte
Contents
[]
byte
RealFile
bool
}
}
// Body returns c.Contents.
// Body returns c.Contents.
...
@@ -65,3 +66,6 @@ func (c CaddyfileInput) Body() []byte { return c.Contents }
...
@@ -65,3 +66,6 @@ func (c CaddyfileInput) Body() []byte { return c.Contents }
// Path returns c.Filepath.
// Path returns c.Filepath.
func
(
c
CaddyfileInput
)
Path
()
string
{
return
c
.
Filepath
}
func
(
c
CaddyfileInput
)
Path
()
string
{
return
c
.
Filepath
}
// Path returns true if the original input was a real file on the file system.
func
(
c
CaddyfileInput
)
IsFile
()
bool
{
return
c
.
RealFile
}
caddy/sigtrap_posix.go
View file @
bb6613d0
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
package
caddy
package
caddy
import
(
import
(
"io/ioutil"
"log"
"log"
"os"
"os"
"os/signal"
"os/signal"
...
@@ -17,7 +18,23 @@ func init() {
...
@@ -17,7 +18,23 @@ func init() {
for
{
for
{
<-
reload
<-
reload
err
:=
Restart
(
nil
)
var
updatedCaddyfile
Input
caddyfileMu
.
Lock
()
if
caddyfile
.
IsFile
()
{
body
,
err
:=
ioutil
.
ReadFile
(
caddyfile
.
Path
())
if
err
==
nil
{
caddyfile
=
CaddyfileInput
{
Filepath
:
caddyfile
.
Path
(),
Contents
:
body
,
RealFile
:
true
,
}
}
}
caddyfileMu
.
Unlock
()
err
:=
Restart
(
updatedCaddyfile
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
err
)
log
.
Println
(
err
)
}
}
...
...
main.go
View file @
bb6613d0
...
@@ -92,6 +92,7 @@ func loadCaddyfile() (caddy.Input, error) {
...
@@ -92,6 +92,7 @@ func loadCaddyfile() (caddy.Input, error) {
return
caddy
.
CaddyfileInput
{
return
caddy
.
CaddyfileInput
{
Contents
:
contents
,
Contents
:
contents
,
Filepath
:
conf
,
Filepath
:
conf
,
RealFile
:
true
,
},
nil
},
nil
}
}
...
@@ -115,6 +116,7 @@ func loadCaddyfile() (caddy.Input, error) {
...
@@ -115,6 +116,7 @@ func loadCaddyfile() (caddy.Input, error) {
return
caddy
.
CaddyfileInput
{
return
caddy
.
CaddyfileInput
{
Contents
:
contents
,
Contents
:
contents
,
Filepath
:
caddy
.
DefaultConfigFile
,
Filepath
:
caddy
.
DefaultConfigFile
,
RealFile
:
true
,
},
nil
},
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