Skip to content

Commit

Permalink
On Unix support using a system-installed jsvc rather than the embed…
Browse files Browse the repository at this point in the history
…ded one through the `capsule.daemon.jsvc` property (#6)
  • Loading branch information
circlespainter committed Feb 16, 2016
1 parent f6cb1f1 commit 0141e9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The following additional manifest entries and system properties can be used to c
- `capsule.daemon.checkOnly`: `jsvc` check run, won't start the service.
- `capsule.daemon.debug`: turn on debug `jsvc` logging.
- `capsule.daemon.verbose`: turn on verbose `jsvc` logging.
- `capsule.daemon.jsvc`: specifies the pathname of a system-installed `jsvc` command to be used instead of the one provided by `capsule-daemon`.
- Manifest entries:
- `Init-Class`: class containing the `init` method (default: none).
- `Init-Method`: static `String[] -> String[]` service initialization method, it will be run as `root`; the return value will be passed to the `Start` method (default: none).
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/DaemonCapsule.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class DaemonCapsule extends Capsule {
private static final String PROP_CHECK_ONLY = "capsule.daemon.checkOnly";
private static final String PROP_DEBUG = "capsule.daemon.debug";
private static final String PROP_VERBOSE = "capsule.daemon.verbose";
private static final String PROP_JSVC = "capsule.daemon.jsvc";

private static final Map.Entry<String, String> ATTR_INIT_CLASS = ATTRIBUTE("Init-Class", T_STRING(), null, true, "Class containing the init method (default: none, Unix only)");
private static final Map.Entry<String, String> ATTR_INIT_METHOD = ATTRIBUTE("Init-Method", T_STRING(), null, true, "Static 'String[] -> String[]' service initialization method short name run as 'root'; the return value will be passed to the 'Start' method (default: none, Unix only)");
Expand All @@ -115,8 +116,14 @@ public DaemonCapsule(Capsule pred) {

@Override
protected Path getJavaExecutable() {
if (svcExec == null)
if (svcExec == null) {
if (isUnix()) {
final String systemJsvc = getProperty(PROP_JSVC);
if (systemJsvc != null)
return (svcExec = Paths.get(systemJsvc));
}
svcExec = setupBinDir().resolve(platformExecPath()).toAbsolutePath().normalize();
}
return svcExec;
}

Expand Down

0 comments on commit 0141e9e

Please sign in to comment.