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

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

Open
yvesdm opened this issue Jun 24, 2016 · 5 comments
Open
Assignees
Labels

Comments

@yvesdm
Copy link

yvesdm commented Jun 24, 2016

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.

@circlespainter circlespainter self-assigned this Jun 26, 2016
yvesdm added a commit to yvesdm/capsule-daemon that referenced this issue Jun 29, 2016
Start/stop in jvm mode instead of java mode.
This change will enable the use of Daemon-Start-Method and Daemon-Stop-Method. See issue puniverse#13
@yvesdm
Copy link
Author

yvesdm commented Jun 29, 2016

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

  • I don't know the reason why java mode was choosen instead of jvm (may be you had a good reason, and may be you prefer to make it configurable -> but will requires to update documentation)
  • I don't know if the list of path to jvm.dll is complete -> see findJvmDll(), and don't know if returnon "auto" is a good idea.

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

Let me know if you have any remarks.

@circlespainter
Copy link
Member

circlespainter commented Jun 29, 2016

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
Copy link
Author

yvesdm commented Jun 29, 2016

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.

  • Using the java way requires to develop IPC (inter process communication) as the main method is called to start and stop the process. It means, one JVM is launched to start the application,and another JVM is launched to handle the stop request. We need an IPC between both of them to notify the first one to shutdown.
  • Using the jvm way, it starts only one JVM it means start and stop will executes under the same context, and may use same object instances. It is more easyier in my use case.

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
Copy link
Author

yvesdm commented Jun 30, 2016

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

  • --User : enables running applications as a service under an account without the LogonAsService privilege
  • --ServiceUser the name of the account under which the service should run

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
Copy link
Member

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.

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

No branches or pull requests

2 participants