Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
2f96652b
Commit
2f96652b
authored
Jun 26, 2014
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interrupt handlers now ordered
parent
9a06efd0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
16 deletions
+24
-16
main.go
ethereal/main.go
+8
-4
cmd.go
ethereum/cmd.go
+0
-1
main.go
ethereum/main.go
+2
-0
cmd.go
utils/cmd.go
+14
-11
No files found.
ethereal/main.go
View file @
2f96652b
...
...
@@ -8,10 +8,12 @@ import (
)
func
main
()
{
qml
.
Init
(
nil
)
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
utils
.
HandleInterrupt
()
qml
.
Init
(
nil
)
// precedence: code-internal flag default < config file < environment variables < command line
Init
()
// parsing command line
utils
.
InitConfig
(
ConfigFile
,
Datadir
,
Identifier
,
"ETH"
)
...
...
@@ -33,8 +35,10 @@ func main() {
utils
.
StartRpc
(
ethereum
,
RpcPort
)
}
utils
.
StartEthereum
(
ethereum
,
UseSeed
)
gui
:=
ethui
.
New
(
ethereum
,
LogLevel
)
gui
.
Start
(
AssetPath
)
utils
.
StartEthereum
(
ethereum
,
UseSeed
)
}
ethereum/cmd.go
View file @
2f96652b
...
...
@@ -12,7 +12,6 @@ func InitJsConsole(ethereum *eth.Ethereum) {
go
repl
.
Start
()
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
repl
.
Stop
()
ethereum
.
Stop
()
})
}
...
...
ethereum/main.go
View file @
2f96652b
...
...
@@ -11,6 +11,8 @@ var logger = ethlog.NewLogger("CLI")
func
main
()
{
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
utils
.
HandleInterrupt
()
// precedence: code-internal flag default < config file < environment variables < command line
Init
()
// parsing command line
utils
.
InitConfig
(
ConfigFile
,
Datadir
,
Identifier
,
"ETH"
)
...
...
utils/cmd.go
View file @
2f96652b
...
...
@@ -18,16 +18,23 @@ import (
)
var
logger
=
ethlog
.
NewLogger
(
"CLI"
)
var
interruptCallbacks
=
[]
func
(
os
.
Signal
){}
// Register interrupt handlers
// Register interrupt handlers
callbacks
func
RegisterInterrupt
(
cb
func
(
os
.
Signal
))
{
interruptCallbacks
=
append
(
interruptCallbacks
,
cb
)
}
// go routine that call interrupt handlers in order of registering
func
HandleInterrupt
()
{
c
:=
make
(
chan
os
.
Signal
,
1
)
go
func
()
{
// Buffered chan of one is enough
c
:=
make
(
chan
os
.
Signal
,
1
)
// Notify about interrupts for now
signal
.
Notify
(
c
,
os
.
Interrupt
)
for
sig
:=
range
c
{
cb
(
sig
)
logger
.
Errorf
(
"Shutting down (%v) ...
\n
"
,
sig
)
for
_
,
cb
:=
range
interruptCallbacks
{
cb
(
sig
)
}
}
}()
}
...
...
@@ -109,13 +116,12 @@ func NewEthereum(UseUPnP bool, OutboundPort string, MaxPeer int) *eth.Ethereum {
func
StartEthereum
(
ethereum
*
eth
.
Ethereum
,
UseSeed
bool
)
{
logger
.
Infof
(
"Starting Ethereum v%s"
,
ethutil
.
Config
.
Ver
)
ethereum
.
Start
(
UseSeed
)
// Wait for shutdown
ethereum
.
WaitForShutdown
()
RegisterInterrupt
(
func
(
sig
os
.
Signal
)
{
logger
.
Errorf
(
"Shutting down (%v) ...
\n
"
,
sig
)
ethereum
.
Stop
()
ethlog
.
Flush
()
})
// this blocks the thread
ethereum
.
WaitForShutdown
()
}
func
ShowGenesis
(
ethereum
*
eth
.
Ethereum
)
{
...
...
@@ -174,9 +180,6 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
logger
.
Errorf
(
"Could not start RPC interface (port %v): %v"
,
RpcPort
,
err
)
}
else
{
go
ethereum
.
RpcServer
.
Start
()
RegisterInterrupt
(
func
(
os
.
Signal
)
{
ethereum
.
RpcServer
.
Stop
()
})
}
}
...
...
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