Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
b3ea4995
Commit
b3ea4995
authored
Nov 09, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/ipfs2: Handle SIGTERM
parent
cc519c47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
cmd/ipfs2/main.go
cmd/ipfs2/main.go
+16
-0
No files found.
cmd/ipfs2/main.go
View file @
b3ea4995
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"os/signal"
"runtime/pprof"
logging
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-logging"
...
...
@@ -31,6 +32,8 @@ const (
var
ofi
io
.
WriteCloser
func
main
()
{
handleInterrupt
()
args
:=
os
.
Args
[
1
:
]
req
,
root
:=
createRequest
(
args
)
handleOptions
(
req
,
root
)
...
...
@@ -299,6 +302,19 @@ func writeHeapProfileToFile() error {
return
pprof
.
WriteHeapProfile
(
mprof
)
}
// listen for and handle SIGTERM
func
handleInterrupt
()
{
c
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
c
,
os
.
Interrupt
)
go
func
()
{
for
_
=
range
c
{
log
.
Info
(
"Received interrupt signal, terminating..."
)
exit
(
0
)
}
}()
}
func
exit
(
code
int
)
{
if
u
.
Debug
{
pprof
.
StopCPUProfile
()
...
...
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