Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blockchain
nucleo
Commits
d2d75838
Commit
d2d75838
authored
5 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
singlestart.sh/reaper now handles SIGCHLD (and better)
parent
0beb18ec
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/singlestart.sh
+28
-9
28 additions, 9 deletions
bin/singlestart.sh
with
28 additions
and
9 deletions
bin/singlestart.sh
+
28
−
9
View file @
d2d75838
...
...
@@ -9,22 +9,34 @@ bootnodekeyfile=${BFANETWORKDIR}/bootnode/key
# Bail out if anything fails.
trap
"exit 1"
ERR
trap
"reaper"
SIGINT
# Detect children dying
trap
"reaper"
SIGINT SIGCHLD
unset
LOGDIR LOGPIPE PIDIDX
declare
-A
PIDIDX
function
reaper
()
{
local
rc
local
wecare
=
0
for
pid
in
${
!PIDIDX[*]
}
do
kill
-0
$pid
2>/dev/null
&&
continue
rc
=
wait
$pid
local
rc
=
0
wait
$pid
||
rc
=
$?
||
true
echo
"***
${
PIDIDX
[
$pid
]
}
(pid
$pid
) has exited with value
$rc
"
unset
PIDIDX[
$pid
]
wecare
=
1
done
test
$wecare
=
1
||
return
# kill all - an extra kill doesn't hurt. I hope.
kill
${
!PIDIDX[*]
}
2>/dev/null
||
true
for
pid
in
${
!PIDIDX[*]
}
do
# don't kill log.sh, because it may still be logging for us
if
[
"
${
PIDIDX
[
$pid
]
}
"
!=
"log.sh"
]
then
echo
"*** Killing
${
PIDIDX
[
$pid
]
}
(pid
$pid
)."
kill
$pid
||
true
fi
done
max
=
30
}
...
...
@@ -73,27 +85,34 @@ LOGPIPE=${LOGDIR}/logpipe
mknod
${
LOGPIPE
}
p
${
BFAHOME
}
/bin/log.sh
${
BFANODEDIR
}
/log <
${
LOGPIPE
}
&
PIDIDX[
$!
]=
"log.sh"
exec
>
${
LOGPIPE
}
2>&1
echo
"*** Starting geth."
geth
--config
${
BFATOML
}
--gcmode
archive
--verbosity
${
BFAVERBOSITY
:-
3
}
--allow-insecure-unlock
>
${
LOGPIPE
}
2>&1
&
geth
--config
${
BFATOML
}
--gcmode
archive
--verbosity
${
BFAVERBOSITY
:-
3
}
--allow-insecure-unlock
&
PIDIDX[
$!
]=
"geth"
# bootnode
if
[
-r
"
$bootnodekeyfile
"
]
then
echo
"*** Starting bootnode."
bootnode
--nodekey
$bootnodekeyfile
>
${
LOGPIPE
}
2>&1
&
bootnode
--nodekey
$bootnodekeyfile
&
PIDIDX[
$!
]=
"bootnode"
fi
echo
"*** Starting monitor.js"
monitor.js
>
${
LOGPIPE
}
2>&1
&
monitor.js &
PIDIDX[
$!
]=
"monitor.js"
max
=
-1
while
[
-n
"
${
!PIDIDX[*]
}
"
-a
$max
-ne
0
]
# Exit if only 1 process remains - we hope it is log.sh, but either way,
# it is time to end.
while
[
"
${#
PIDIDX
[*]
}
"
-gt
1
-a
$max
-ne
0
]
do
sleep
1
max
=
$((
$max
-
1
))
done
kill
-KILL
${
!PIDIDX[*]
}
2>/dev/null
||
true
if
[
${#
PIDIDX
[*]
}
-gt
0
]
then
echo
"*** Killing all remaining processes:
${
PIDIDX
[*]
}
(
${
!PIDIDX[*]
}
)."
kill
-KILL
${
!PIDIDX[*]
}
2>/dev/null
||
true
fi
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