Skip to content

Commit e5ee3aa

Browse files
committed
changed template for /etc/init/{{app_name}} This seems to fix issue sbt#357 for Ubuntu 14.04.
1 parent 7cc2e09 commit e5ee3aa

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/main/resources/com/typesafe/sbt/packager/archetypes/upstart/start-debian-template

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,22 @@ author "${{author}}"
1010

1111
# When to start the service
1212
start on runlevel ${{start_runlevels}}
13-
start on started ${{start_facilities}}
1413

1514
# When to stop the service
1615
stop on runlevel ${{stop_runlevels}}
17-
stop on stopping ${{stop_facilities}}
1816

1917
# Automatically restart process if crashed. Tries ${{retries}} times every ${{retryTimeout}} seconds
2018
respawn
2119
respawn limit ${{retries}} ${{retryTimeout}}
2220

21+
pre-start script
22+
[ -d /var/run/${{app_name}} ] || install -m 755 -o ${{daemon_user}} -g ${{daemon_user}} -d /var/run/${{app_name}}
23+
end script
24+
2325
# set the working directory of the job processes
2426
chdir ${{chdir}}
2527

26-
# changes to the user and group before running the job's process
27-
setuid ${{daemon_user}}
28-
2928
# Start the process
3029
script
31-
exec ./bin/${{exec}}
30+
exec sudo -u ${{daemon_user}} ./bin/${{exec}}
3231
end script

src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object JavaServerAppPackaging {
5151
private[this] def defaultFacilities(loader: ServerLoader): String = {
5252
loader match {
5353
case SystemV => "$remote_fs $syslog"
54-
case Upstart => "[networking]"
54+
case Upstart => ""
5555
case Systemd => "network.target"
5656
}
5757
}

src/sbt-test/debian/upstart-deb/build.sbt

-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ InputKey[Unit]("check-softlink") <<= inputTask { (argTask: TaskKey[Seq[String]])
4747
TaskKey[Unit]("check-startup-script") <<= (target, streams) map { (target, out) =>
4848
val script = IO.read(target / "debian-test-0.1.0" / "etc" / "init" / "debian-test.conf")
4949
assert(script.contains("start on runlevel [2345]"), "script doesn't contain start on runlevel header\n" + script)
50-
assert(script.contains("start on started [networking]"), "script doesn't contain start on [networking] header\n" + script)
5150
assert(script.contains("stop on runlevel [016]"), "script doesn't contain stop on runlevel header\n" + script)
52-
assert(script.contains("stop on stopping [networking]"), "script doesn't contain stop on [networking] header\n" + script)
5351
out.log.success("Successfully tested systemV start up script")
5452
()
5553
}

0 commit comments

Comments
 (0)