Skip to content

Commit 68e95f7

Browse files
mr-gitmuuki88
authored andcommitted
#957 RPM with killTimeout (#960)
* #957 RPM with `killTimeout` * #957 replace tabs with spaces * #957 replace tabs with spaces * #957 `rpmbuild` wants to have the `rpmGroup`
1 parent 02519e1 commit 68e95f7

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

src/main/resources/com/typesafe/sbt/packager/archetypes/systemloader/systemd/loader-functions

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ addService() {
99
[ -e "${app_sys_config}" ] && . "${app_sys_config}"
1010
if [ -n "${PACKAGE_PREFIX}" ] ;
1111
then
12-
default_install_location="${{chdir}}"
13-
actual_install_location="${PACKAGE_PREFIX}/${app_name}"
12+
default_install_location="${{chdir}}"
13+
actual_install_location="${PACKAGE_PREFIX}/${app_name}"
1414

15-
sed -i "s|$default_install_location|$actual_install_location|g" "/usr/lib/systemd/system/${app_name}.service"
15+
sed -i "s|$default_install_location|$actual_install_location|g" "/usr/lib/systemd/system/${app_name}.service"
1616
fi
1717

1818
systemctl enable "$app_name.service"
@@ -44,9 +44,9 @@ stopService() {
4444
# $1 = service name
4545
#
4646
restartService() {
47-
app_name=$1
47+
app_name=$1
4848

49-
systemctl daemon-reload
50-
systemctl try-restart "$app_name.service"
49+
systemctl daemon-reload
50+
systemctl try-restart "$app_name.service"
5151
}
5252

src/main/resources/com/typesafe/sbt/packager/archetypes/systemloader/systemv/start-rpm-template

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ start() {
8686

8787
stop() {
8888
echo -n $"Stopping $prog: "
89-
killproc -p $PIDFILE $prog
89+
killproc -p $PIDFILE -d ${{kill_timeout}} $prog
9090
retval=$?
9191
echo
9292
[ $retval -eq 0 ] && rm -f $lockfile

src/sbt-test/rpm/systemd-rpm/build.sbt

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ rpmRelease := "1"
1212
rpmVendor := "typesafe"
1313
rpmUrl := Some("http://github.com/sbt/sbt-native-packager")
1414
rpmLicense := Some("BSD")
15+
rpmGroup := Some("test-group")
1516

1617
requiredStartFacilities in Rpm := Some("serviceA.service")
1718

@@ -47,10 +48,10 @@ TaskKey[Unit]("checkSpecFile") <<= (target, streams) map { (target, out) =>
4748
| [ -e "${app_sys_config}" ] && . "${app_sys_config}"
4849
| if [ -n "${PACKAGE_PREFIX}" ] ;
4950
| then
50-
| default_install_location="/usr/share/rpm-test"
51-
| actual_install_location="${PACKAGE_PREFIX}/${app_name}"
51+
| default_install_location="/usr/share/rpm-test"
52+
| actual_install_location="${PACKAGE_PREFIX}/${app_name}"
5253
|
53-
| sed -i "s|$default_install_location|$actual_install_location|g" "/usr/lib/systemd/system/${app_name}.service"
54+
| sed -i "s|$default_install_location|$actual_install_location|g" "/usr/lib/systemd/system/${app_name}.service"
5455
| fi
5556
|
5657
| systemctl enable "$app_name.service"
@@ -100,10 +101,10 @@ TaskKey[Unit]("checkSpecFile") <<= (target, streams) map { (target, out) =>
100101
|# $1 = service name
101102
|#
102103
|restartService() {
103-
| app_name=$1
104+
| app_name=$1
104105
|
105-
| systemctl daemon-reload
106-
| systemctl try-restart "$app_name.service"
106+
| systemctl daemon-reload
107+
| systemctl try-restart "$app_name.service"
107108
|}
108109
|""".stripMargin,
109110
"rpm restartService() scriptlet is missing or incorrect"

src/sbt-test/rpm/sysvinit-rpm/build.sbt

+16-16
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
7575
|addService() {
7676
| app_name=$1
7777
| if hash update-rc.d >/dev/null 2>&1; then
78-
| echo "Adding $app_name to service management using update-rc.d"
79-
| update-rc.d $app_name defaults
78+
| echo "Adding $app_name to service management using update-rc.d"
79+
| update-rc.d $app_name defaults
8080
| elif hash chkconfig >/dev/null 2>&1; then
81-
| echo "Adding $app_name to service management using chkconfig"
82-
| chkconfig --add rpm-test
83-
| chkconfig $app_name on
81+
| echo "Adding $app_name to service management using chkconfig"
82+
| chkconfig --add rpm-test
83+
| chkconfig $app_name on
8484
| else
85-
| echo "WARNING: Could not add $app_name to autostart: neither update-rc nor chkconfig found!"
85+
| echo "WARNING: Could not add $app_name to autostart: neither update-rc nor chkconfig found!"
8686
| fi
8787
|}
8888
|""".stripMargin,
@@ -112,16 +112,16 @@ TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
112112
|stopService() {
113113
| app_name=$1
114114
| if hash update-rc.d >/dev/null 2>&1; then
115-
| echo "Removing $app_name from autostart using update-rc.d"
116-
| update-rc.d -f $app_name remove
117-
| service $app_name stop
115+
| echo "Removing $app_name from autostart using update-rc.d"
116+
| update-rc.d -f $app_name remove
117+
| service $app_name stop
118118
| elif hash chkconfig >/dev/null 2>&1; then
119-
| echo "Removing $app_name from autostart using chkconfig"
120-
| chkconfig $app_name off
121-
| chkconfig --del $app_name
122-
| service $app_name stop
119+
| echo "Removing $app_name from autostart using chkconfig"
120+
| chkconfig $app_name off
121+
| chkconfig --del $app_name
122+
| service $app_name stop
123123
| else
124-
| echo "WARNING: Could not remove $app_name from autostart: neither update-rc nor chkconfig found!"
124+
| echo "WARNING: Could not remove $app_name from autostart: neither update-rc nor chkconfig found!"
125125
| fi
126126
|}
127127
|""".stripMargin,
@@ -135,8 +135,8 @@ TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
135135
|# $1 = service name
136136
|#
137137
|restartService() {
138-
| app_name=$1
139-
| service $app_name restart
138+
| app_name=$1
139+
| service $app_name restart
140140
|}
141141
|""".stripMargin,
142142
"rpm restartService() scriptlet is missing or incorrect"

0 commit comments

Comments
 (0)