puniverse / capsule-daemon

A caplet that will run a capsule as a daemon
http://capsule.io
14 stars 4 forks source link

Daemon-Start-Method / Daemon-Stop-Method doesn't works with procrun ! #13

Open yvesdm opened 8 years ago

yvesdm commented 8 years ago

Since the process is started/stopped in Java Mode : see DaemonCapsule.java

        installCmd.add(i++, "--StartMode");
        installCmd.add(i++, "Java");
...
        installCmd.add(i++, "--StopMode");
        installCmd.add(i++, "Java");

and according to the spec of procRun :

Name of method to be called when service is started. It must be static void and have argument (String args[]). Only applies to jvm mode - in Java mode, the main method is always used. ... Name of method to be called when service is stopped. It must be static void and have argument (String args[]). Only applies to jvm mode. In Java mode, the main method is always used.

It will never works as expected.

Yves.

yvesdm commented 8 years ago

Solution proposed -> see pull request.

Don't know if it is the way you wanted to solve this as I changed the mode java to mode jvm. So open questions are

But I tested on my windows 7, 64 bits, and it works as expected.

Let me know if you have any remarks.

circlespainter commented 8 years ago

The main reason for java was to allow running the application as a service under an account without the LogonAsService privilege. Thanks for the PR, an alternative I was thinking about was to simply fix the documentation to state that start/stop methods don't apply to Windows.

What is your use case for start/stop methods under Windows?

yvesdm commented 8 years ago

My use case is : run an Apache Camel based application as a windows service. So I have a start method to launch Camel, and another one to stop it.

But you are true, it breaks the feature LogonAsService. To provide both features (start/stop method and LogonAsService, the mode should became configurable and the doc should be updated. But should be easy to do :)

yvesdm commented 8 years ago

Regarding the the feature LogonAsService, There are 2 options available in procrun

Note : I see both of them are currently available in the capsule daemon.

If we choose for mode JVM, I guess the jvm will run under the user specified in ServiceUser and then having the same feature.

Do you have any specific use case where an application should be run in Java mode instead of in JVM mode ?

circlespainter commented 8 years ago

No specific use case (yet) but I'd avoid dropping --User without understanding the consequences, which I don't really understand; also, I can't test on a Windows system right now. Is the matter any clearer to you and do you have a chance of testing your PR with --ServiceUser with an account lacking the LogonAsService privilege?

I still think the best solution would be to add a mode option as you suggested though.