Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
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
DEMO
spring-boot
Commits
75186d42
Commit
75186d42
authored
Dec 30, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6223 from gauravbrills/patch-1
* pr/6223: Add `force-stop` support to launch script
parents
3c930347
509be747
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
0 deletions
+36
-0
SysVinitLaunchScriptIT.java
...ngframework/boot/launchscript/SysVinitLaunchScriptIT.java
+8
-0
force-stop-when-stopped.sh
...sts/src/test/resources/scripts/force-stop-when-stopped.sh
+4
-0
test-functions.sh
...script-tests/src/test/resources/scripts/test-functions.sh
+4
-0
launch.script
...urces/org/springframework/boot/loader/tools/launch.script
+20
-0
No files found.
spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java
View file @
75186d42
...
...
@@ -118,6 +118,14 @@ public class SysVinitLaunchScriptIT {
.
has
(
coloredString
(
AnsiColor
.
YELLOW
,
"Not running (pidfile not found)"
));
}
@Test
public
void
forceStopWhenStopped
()
throws
Exception
{
String
output
=
doTest
(
"force-stop-when-stopped.sh"
);
assertThat
(
output
).
contains
(
"Status: 0"
);
assertThat
(
output
)
.
has
(
coloredString
(
AnsiColor
.
YELLOW
,
"Not running (pidfile not found)"
));
}
@Test
public
void
startWhenStarted
()
throws
Exception
{
String
output
=
doTest
(
"start-when-started.sh"
);
...
...
spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/force-stop-when-stopped.sh
0 → 100644
View file @
75186d42
source
./test-functions.sh
install_service
force_stop_service
echo
"Status:
$?
"
spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh
View file @
75186d42
...
...
@@ -21,6 +21,10 @@ stop_service() {
service spring-boot-app stop
}
force_stop_service
()
{
service spring-boot-app force-stop
}
await_app
()
{
if
[
-z
$1
]
then
...
...
spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script
View file @
75186d42
...
...
@@ -203,6 +203,24 @@ do_stop() {
return
1
;
}
force_stop
()
{
[[
-f
$pid_file
]]
||
{
echoYellow
"Not running (pidfile not found)"
;
return
0
;
}
pid
=
$(
cat
"
$pid_file
"
)
isRunning
"
$pid
"
||
{
echoYellow
"Not running (process
${
pid
}
). Removing stale pid file."
;
rm
-f
"
$pid_file
"
;
return
0
;
}
do_force_stop
"
$pid
"
"
$pid_file
"
}
do_force_stop
()
{
kill
-9
"
$1
"
&> /dev/null
||
{
echoRed
"Unable to kill process
$1
"
;
return
1
;
}
for
i
in
$(
seq
1 60
)
;
do
isRunning
"
$1
"
||
{
echoGreen
"Stopped [
$1
]"
;
rm
-f
"
$2
"
;
return
0
;
}
[[
$i
-eq
30
]]
&&
kill
-9
"
$1
"
&> /dev/null
sleep
1
done
echoRed
"Unable to kill process
$1
"
;
return
1
;
}
restart
()
{
stop
&&
start
}
...
...
@@ -242,6 +260,8 @@ start)
start
"
$@
"
;
exit
$?
;;
stop
)
stop
"
$@
"
;
exit
$?
;;
force-stop
)
force_stop
"
$@
"
;
exit
$?
;;
restart
)
restart
"
$@
"
;
exit
$?
;;
force-reload
)
...
...
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