Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kubo_final
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anastasiia Chirikova
kubo_final
Commits
8cf765af
Commit
8cf765af
authored
10 years ago
by
Juan Batiz-Benet
Browse files
Options
Downloads
Patches
Plain Diff
daemon: listen for term signals
parent
3df1513e
Branches
Branches containing commit
No related tags found
1 merge request
!1
New
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/ipfs2/daemon.go
+39
-6
39 additions, 6 deletions
cmd/ipfs2/daemon.go
server/http/http.go
+1
-1
1 addition, 1 deletion
server/http/http.go
tour/chapter.go
+1
-1
1 addition, 1 deletion
tour/chapter.go
with
41 additions
and
8 deletions
cmd/ipfs2/daemon.go
+
39
−
6
View file @
8cf765af
...
...
@@ -3,10 +3,14 @@ package main
import
(
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr/net"
manners
"github.com/braintree/manners"
cmds
"github.com/jbenet/go-ipfs/commands"
cmdsHttp
"github.com/jbenet/go-ipfs/commands/http"
core
"github.com/jbenet/go-ipfs/core"
...
...
@@ -63,18 +67,47 @@ func daemonFunc(req cmds.Request) (interface{}, error) {
return
nil
,
err
}
mux
:=
http
.
NewServeMux
()
cmdHandler
:=
cmdsHttp
.
NewHandler
(
*
req
.
Context
(),
commands
.
Root
)
http
.
Handle
(
cmdsHttp
.
ApiPath
+
"/"
,
cmdHandler
)
mux
.
Handle
(
cmdsHttp
.
ApiPath
+
"/"
,
cmdHandler
)
ifpsHandler
:=
&
ipfsHandler
{
node
}
http
.
Handle
(
"/ipfs/"
,
ifpsHandler
)
mux
.
Handle
(
"/ipfs/"
,
ifpsHandler
)
err
=
listenAndServe
(
mux
,
host
)
return
nil
,
err
}
func
listenAndServe
(
mux
*
http
.
ServeMux
,
host
string
)
error
{
fmt
.
Printf
(
"API server listening on '%s'
\n
"
,
host
)
s
:=
manners
.
NewServer
()
done
:=
make
(
chan
struct
{},
1
)
defer
func
()
{
done
<-
struct
{}{}
}()
err
=
http
.
ListenAndServe
(
host
,
nil
)
if
err
!=
nil
{
return
nil
,
err
// go wait until we kill it.
go
func
()
{
sig
:=
sigTerm
()
select
{
case
<-
done
:
log
.
Info
(
"daemon terminated at %s."
,
host
)
case
<-
sig
:
s
.
Shutdown
<-
true
log
.
Info
(
"terminating daemon at %s..."
,
host
)
}
}()
if
err
:=
s
.
ListenAndServe
(
host
,
mux
);
err
!=
nil
{
return
err
}
return
nil
}
return
nil
,
nil
func
sigTerm
()
chan
os
.
Signal
{
sigc
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
sigc
,
syscall
.
SIGHUP
,
syscall
.
SIGINT
,
syscall
.
SIGTERM
,
syscall
.
SIGQUIT
)
return
sigc
}
This diff is collapsed.
Click to expand it.
server/http/http.go
+
1
−
1
View file @
8cf765af
...
...
@@ -6,7 +6,7 @@ import (
"io"
"net/http"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gorilla/mux"
mux
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gorilla/mux"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr/net"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
...
...
This diff is collapsed.
Click to expand it.
tour/chapter.go
+
1
−
1
View file @
8cf765af
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment