Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First line of Unix launch script is empty, causes Exec format error with systemd #121

Closed
woky opened this issue Nov 5, 2017 · 2 comments

Comments

@woky
Copy link

woky commented Nov 5, 2017

Create very simple systemd service file in /etc/systemd/system/foo.service to start the program by the launch script (start) created by pack:

[Service]
ExecStart=/opt/foo/bin/start

Start the service: systemctl start foo

The service won't start and the following will appear in journal (journalctl -n20):

Nov 05 20:50:26 myhost systemd[291]: foo.service: Failed to execute command: Exec format error
Nov 05 20:50:26 myhost systemd[291]: foo.service: Failed at step EXEC spawning /opt/foo/bin/start: Exec format error

The problem is that the first line of the launch script is empty line. I think systemd is being correct (and perhaps strict) here. The shebang line should be the first line in the file.

Perhaps the fix could be something like this?

diff --git a/src/main/twirl/xerial/sbt/pack/launch.scala.txt b/src/main/twirl/xerial/sbt/pack/launch.scala.txt
index 632d466..1a13ffd 100644
--- a/src/main/twirl/xerial/sbt/pack/launch.scala.txt
+++ b/src/main/twirl/xerial/sbt/pack/launch.scala.txt
@@ -1,5 +1,4 @@
-@(opts:xerial.sbt.pack.LaunchScript.Opts, expandedClasspath:Option[String])
-#!/bin/sh
+@(opts:xerial.sbt.pack.LaunchScript.Opts, expandedClasspath:Option[String])#!/bin/sh
 #/*--------------------------------------------------------------------------
 # *  Copyright 2012 Taro L. Saito
 # *
@woky
Copy link
Author

woky commented Nov 5, 2017

oops, duplicate of #119

@woky woky closed this as completed Nov 5, 2017
@karanjamutahi
Copy link

Legend. You just saved me an hour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants