I'm using authbind
to allow my Play Framework app to bind to port 80 when run as a non-root user.
My target/start script needs to look like this for it to work:
#!/usr/bin/env sh
exec authbind --deep java $@ -cp "`dirname $0`/staged/*" play.core.server.NettyServer `dirname $0`/..
At the moment I'm manually modifying this generated file (urgh!). I can't find an elegant way to get play stage
to automatically insert the authbind --deep
before the java command.
This target/start
script is launched from an Upstart script, and I have tried putting authbind --deep
in there, but this doesn't seem to work.
Any ideas would be much appreciated.
Adjust your project/Build.scala file:
lazy val main = play.Project(appName, appVersion, appDependencies).settings(
playStage <<= (playStage, baseDirectory) map {(stageCommand, baseDir) =>
val content = """#!/usr/bin/env sh
|
|exec authbind --deep java $@ -cp "`dirname $0`/staged/*" play.core.server.NettyServer `dirname $0`/..""".stripMargin
IO.write(baseDir / "target" / "start", content)
stageCommand
}
)
This overrides the play stage task and writes a custom start script file.