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
4c30f0f9
Commit
4c30f0f9
authored
Jul 06, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1416 from fjl/one-interrupt
cmd/geth, cmd/utils: improve interrupt handling
parents
fa7b3b72
5615fc47
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
37 deletions
+17
-37
main.go
cmd/geth/main.go
+1
-3
cmd.go
cmd/utils/cmd.go
+16
-34
No files found.
cmd/geth/main.go
View file @
4c30f0f9
...
@@ -347,7 +347,6 @@ func main() {
...
@@ -347,7 +347,6 @@ func main() {
}
}
func
run
(
ctx
*
cli
.
Context
)
{
func
run
(
ctx
*
cli
.
Context
)
{
utils
.
HandleInterrupt
()
cfg
:=
utils
.
MakeEthConfig
(
ClientIdentifier
,
nodeNameVersion
,
ctx
)
cfg
:=
utils
.
MakeEthConfig
(
ClientIdentifier
,
nodeNameVersion
,
ctx
)
ethereum
,
err
:=
eth
.
New
(
cfg
)
ethereum
,
err
:=
eth
.
New
(
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -527,10 +526,9 @@ func blockRecovery(ctx *cli.Context) {
...
@@ -527,10 +526,9 @@ func blockRecovery(ctx *cli.Context) {
func
startEth
(
ctx
*
cli
.
Context
,
eth
*
eth
.
Ethereum
)
{
func
startEth
(
ctx
*
cli
.
Context
,
eth
*
eth
.
Ethereum
)
{
// Start Ethereum itself
// Start Ethereum itself
utils
.
StartEthereum
(
eth
)
utils
.
StartEthereum
(
eth
)
am
:=
eth
.
AccountManager
()
am
:=
eth
.
AccountManager
()
account
:=
ctx
.
GlobalString
(
utils
.
UnlockedAccountFlag
.
Name
)
account
:=
ctx
.
GlobalString
(
utils
.
UnlockedAccountFlag
.
Name
)
accounts
:=
strings
.
Split
(
account
,
" "
)
accounts
:=
strings
.
Split
(
account
,
" "
)
for
i
,
account
:=
range
accounts
{
for
i
,
account
:=
range
accounts
{
...
...
cmd/utils/cmd.go
View file @
4c30f0f9
...
@@ -46,29 +46,6 @@ const (
...
@@ -46,29 +46,6 @@ const (
var
interruptCallbacks
=
[]
func
(
os
.
Signal
){}
var
interruptCallbacks
=
[]
func
(
os
.
Signal
){}
// 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
()
{
signal
.
Notify
(
c
,
os
.
Interrupt
)
for
sig
:=
range
c
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"Shutting down (%v) ...
\n
"
,
sig
)
RunInterruptCallbacks
(
sig
)
}
}()
}
func
RunInterruptCallbacks
(
sig
os
.
Signal
)
{
for
_
,
cb
:=
range
interruptCallbacks
{
cb
(
sig
)
}
}
func
openLogFile
(
Datadir
string
,
filename
string
)
*
os
.
File
{
func
openLogFile
(
Datadir
string
,
filename
string
)
*
os
.
File
{
path
:=
common
.
AbsolutePath
(
Datadir
,
filename
)
path
:=
common
.
AbsolutePath
(
Datadir
,
filename
)
file
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0666
)
file
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0666
)
...
@@ -149,19 +126,24 @@ func StartEthereum(ethereum *eth.Ethereum) {
...
@@ -149,19 +126,24 @@ func StartEthereum(ethereum *eth.Ethereum) {
if
err
:=
ethereum
.
Start
();
err
!=
nil
{
if
err
:=
ethereum
.
Start
();
err
!=
nil
{
Fatalf
(
"Error starting Ethereum: %v"
,
err
)
Fatalf
(
"Error starting Ethereum: %v"
,
err
)
}
}
RegisterInterrupt
(
func
(
sig
os
.
Signal
)
{
go
func
()
{
ethereum
.
Stop
()
sigc
:=
make
(
chan
os
.
Signal
,
1
)
logger
.
Flush
()
signal
.
Notify
(
sigc
,
os
.
Interrupt
)
})
defer
signal
.
Stop
(
sigc
)
}
<-
sigc
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Got interrupt, shutting down..."
)
func
StartEthereumForTest
(
ethereum
*
eth
.
Ethereum
)
{
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Starting "
,
ethereum
.
Name
())
ethereum
.
StartForTest
()
RegisterInterrupt
(
func
(
sig
os
.
Signal
)
{
ethereum
.
Stop
()
ethereum
.
Stop
()
logger
.
Flush
()
logger
.
Flush
()
})
for
i
:=
10
;
i
>
0
;
i
--
{
<-
sigc
if
i
>
1
{
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Already shutting down, please be patient."
)
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Interrupt"
,
i
-
1
,
"more times to induce panic."
)
}
}
glog
.
V
(
logger
.
Error
)
.
Infof
(
"Force quitting: this might not end so well."
)
panic
(
"boom"
)
}()
}
}
func
FormatTransactionData
(
data
string
)
[]
byte
{
func
FormatTransactionData
(
data
string
)
[]
byte
{
...
...
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