You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Hans Rupp <ha...@googlemail.com> on 2011/07/15 14:19:19 UTC

[daemon]

Hi,



i have 2 questions about procrun (i’m using win xp).



1. is it possible to run a jar-file as service, so that at service start the
standard jdk6 splashscreen is showing? I always get null from
getSplashScreen() when running as service, but when I start it from the

 Jar the splashscreen shows up?



2.Is it possible to get rid of or at least minimize the dos-Window of
procrun?



Thanks and regards


Hans

Re: [daemon]

Posted by Hans Rupp <ha...@googlemail.com>.
2011/7/22 Mladen Turk <mt...@apache.org>

> On 07/22/2011 10:34 AM, Hans Rupp wrote:
>
>> 2011/7/21 Mladen Turk<mt...@apache.org>
>>
>>>
>>> So i should have two jvm's, one running my non-gui stuff
>>>
>> as a windows service and one running the gui as a windows
>> task right?  And this two should communicate via IPC
>> e.g tcp/ip right?
>>
>
> Yes.
>
>
>  But isn't that a lot of overhead if i can have it all running in one jvm
>> without IPC?
>>
>
> Sure it is. Same thing you would need on unixes since day 0.
>
>
>  Can please explain why one shouldn't use a service with a gui ? Sorry but
>> i
>> still don't understand that point.
>>
>>
> http://msdn.microsoft.com/en-**us/library/bb203962%28v=vs.85%**29.aspx<http://msdn.microsoft.com/en-us/library/bb203962%28v=vs.85%29.aspx>
> See the section about Session 0 Isolation
>
> I know, I know ...
> You are developing a new application targeted exclusively for XP
> which won't work on any contemporary windoze ;)
>
> Lets not continue this discussion further because
> its getting off-topic.
>
> Ok thank you anyway.

>
> Regards
> --
> ^TM
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [daemon]

Posted by Mladen Turk <mt...@apache.org>.
On 07/22/2011 10:34 AM, Hans Rupp wrote:
> 2011/7/21 Mladen Turk<mt...@apache.org>
>>
>> So i should have two jvm's, one running my non-gui stuff
> as a windows service and one running the gui as a windows
> task right?  And this two should communicate via IPC
> e.g tcp/ip right?

Yes.

> But isn't that a lot of overhead if i can have it all running in one jvm
> without IPC?

Sure it is. Same thing you would need on unixes since day 0.

> Can please explain why one shouldn't use a service with a gui ? Sorry but i
> still don't understand that point.
>

http://msdn.microsoft.com/en-us/library/bb203962%28v=vs.85%29.aspx
See the section about Session 0 Isolation

I know, I know ...
You are developing a new application targeted exclusively for XP
which won't work on any contemporary windoze ;)

Lets not continue this discussion further because
its getting off-topic.


Regards
-- 
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [daemon]

Posted by Hans Rupp <ha...@googlemail.com>.
2011/7/21 Mladen Turk <mt...@apache.org>

> On 07/21/2011 08:58 AM, Hans Rupp wrote:
>
>> 2011/7/19 Mladen Turk<mt...@apache.org>
>>
>>
>>> Well, write an ant task and start your application via ant.
>>> This is the first thing that comes to my mind.
>>> Or write you own simple class that will exec new jvm and
>>> monitor it's exit value.
>>>
>>> Thanks again, but i'm not familiar with ant and don't how to write a task
>>>
>> that can permanently monitor my application.
>>
>
> So you are out of luck then ;)
>
>
>  I think your second suggestion isn't realy a solution, what should i do if
>> the monitoring jvm crashes?
>>
>
> That's why its called "monitoring" it doesn't do any job except
> checking if the child is alive, and if not restart it according to
> some rules. People even write this kind of layer for standard services,
> because your application can become unresponsive without
> crashing the JVM. Also if you think your application could
> crash the JVM your are in much bigger problem.
>
> I think your entire use case is sort of an oxymoron.
> You wish a full blown service (like you've said "os-layer")
> and still to have the userland GUI. Split those two parts
> and use the IPC for communication between them.
>
>
> So i should have two jvm's, one running my non-gui stuff
as a windows service and one running the gui as a windows
task right?  And this two should communicate via IPC
e.g tcp/ip right?
But isn't that a lot of overhead if i can have it all running in one jvm
without IPC?
Can please explain why one shouldn't use a service with a gui ? Sorry but i
still don't understand that point.

>
>
> Regards
> --
> ^TM
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [daemon]

Posted by Mladen Turk <mt...@apache.org>.
On 07/21/2011 08:58 AM, Hans Rupp wrote:
> 2011/7/19 Mladen Turk<mt...@apache.org>
>
>>
>> Well, write an ant task and start your application via ant.
>> This is the first thing that comes to my mind.
>> Or write you own simple class that will exec new jvm and
>> monitor it's exit value.
>>
>> Thanks again, but i'm not familiar with ant and don't how to write a task
> that can permanently monitor my application.

So you are out of luck then ;)

> I think your second suggestion isn't realy a solution, what should i do if
> the monitoring jvm crashes?

That's why its called "monitoring" it doesn't do any job except
checking if the child is alive, and if not restart it according to
some rules. People even write this kind of layer for standard services,
because your application can become unresponsive without
crashing the JVM. Also if you think your application could
crash the JVM your are in much bigger problem.

I think your entire use case is sort of an oxymoron.
You wish a full blown service (like you've said "os-layer")
and still to have the userland GUI. Split those two parts
and use the IPC for communication between them.



Regards
-- 
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [daemon]

Posted by ad...@gmail.com.
Yes. In Nix a cron job would monitor for exit status and call ant to restart. You need to ensure consistent state for restart

Adam
Sent using BlackBerry® from Orange

-----Original Message-----
From: Hans Rupp <ha...@googlemail.com>
Date: Thu, 21 Jul 2011 08:58:05 
To: Commons Users List<us...@commons.apache.org>
Reply-To: "Commons Users List" <us...@commons.apache.org>
Subject: Re: [daemon]

2011/7/19 Mladen Turk <mt...@apache.org>

> On 07/19/2011 10:17 AM, Hans Rupp wrote:
>
>> 2011/7/18 Mladen Turk<mt...@apache.org>
>>
>>
>>>  Thank you, this meets my first and third requirement, but how about the
>>>
>> second  one:
>>  Application must be able to recover automatically from jvm crashes
>> (service
>> restarts when terminated abnormally)
>> How can i achieve this with tasks?
>>
>
> Well, write an ant task and start your application via ant.
> This is the first thing that comes to my mind.
> Or write you own simple class that will exec new jvm and
> monitor it's exit value.
>
> Thanks again, but i'm not familiar with ant and don't how to write a task
that can permanently monitor my application.
I think your second suggestion isn't realy a solution, what should i do if
the monitoring jvm crashes?
I don't see how to achieve this on the "java/jvm"-layer, thats why i come to
"windows"-services which are "os"-layer (i mean a layer that can control jvm
from outside a jvm via the restart option)


>
> Regards
> --
> ^TM
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>


Re: [daemon]

Posted by Hans Rupp <ha...@googlemail.com>.
2011/7/19 Mladen Turk <mt...@apache.org>

> On 07/19/2011 10:17 AM, Hans Rupp wrote:
>
>> 2011/7/18 Mladen Turk<mt...@apache.org>
>>
>>
>>>  Thank you, this meets my first and third requirement, but how about the
>>>
>> second  one:
>>  Application must be able to recover automatically from jvm crashes
>> (service
>> restarts when terminated abnormally)
>> How can i achieve this with tasks?
>>
>
> Well, write an ant task and start your application via ant.
> This is the first thing that comes to my mind.
> Or write you own simple class that will exec new jvm and
> monitor it's exit value.
>
> Thanks again, but i'm not familiar with ant and don't how to write a task
that can permanently monitor my application.
I think your second suggestion isn't realy a solution, what should i do if
the monitoring jvm crashes?
I don't see how to achieve this on the "java/jvm"-layer, thats why i come to
"windows"-services which are "os"-layer (i mean a layer that can control jvm
from outside a jvm via the restart option)


>
> Regards
> --
> ^TM
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [daemon]

Posted by Mladen Turk <mt...@apache.org>.
On 07/19/2011 10:17 AM, Hans Rupp wrote:
> 2011/7/18 Mladen Turk<mt...@apache.org>
>
>>
>>   Thank you, this meets my first and third requirement, but how about the
> second  one:
>   Application must be able to recover automatically from jvm crashes (service
> restarts when terminated abnormally)
> How can i achieve this with tasks?

Well, write an ant task and start your application via ant.
This is the first thing that comes to my mind.
Or write you own simple class that will exec new jvm and
monitor it's exit value.


Regards
-- 
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [daemon]

Posted by Hans Rupp <ha...@googlemail.com>.
2011/7/18 Mladen Turk <mt...@apache.org>

> On 07/18/2011 04:49 PM, Hans Rupp wrote:
>
>> 2011/7/18 Mladen Turk<mt...@apache.org>
>>
>>  But it would very nice, if you can give me some hints, how to do it a
>> better way.
>>
>>
> Here is one option:
>
> Start -> All Programs -> Accessories -> System Tools -> Scheduled Tasks
>
> Click on Add Scheduled Task
> Click Next
> Click Browse
>  ... select you JAVA_HOME\bin\javaw.exe
>     Name your task. eg. My Fancy task
>     Click on "When my computer starts"
>
> Enter username and password
> Set additional command line properties like you would
> when invoking javaw from the command line.
> If you app doesn't work with javaw you are out of luck :)
>
>
> Cheers
>
>  Thank you, this meets my first and third requirement, but how about the
second  one:
 Application must be able to recover automatically from jvm crashes (service
restarts when terminated abnormally)
How can i achieve this with tasks?

> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [daemon]

Posted by Mladen Turk <mt...@apache.org>.
On 07/18/2011 04:49 PM, Hans Rupp wrote:
> 2011/7/18 Mladen Turk<mt...@apache.org>
>
>   But it would very nice, if you can give me some hints, how to do it a
> better way.
>

Here is one option:

Start -> All Programs -> Accessories -> System Tools -> Scheduled Tasks

Click on Add Scheduled Task
Click Next
Click Browse
  ... select you JAVA_HOME\bin\javaw.exe
      Name your task. eg. My Fancy task
      Click on "When my computer starts"

Enter username and password
Set additional command line properties like you would
when invoking javaw from the command line.
If you app doesn't work with javaw you are out of luck :)


Cheers
-- 
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [daemon]

Posted by Hans Rupp <ha...@googlemail.com>.
2011/7/18 Mladen Turk <mt...@apache.org>

> On 07/18/2011 09:21 AM, Hans Rupp wrote:
>
>> 2011/7/15 Mladen Turk<mt...@apache.org>
>>
>>
>>>>  There is no window if started as service.
>>> Are you referring starting the procrun from user session?
>>> Why would you wish to do that?
>>>
>>>
>>>
>>>  Thanks for your answer.
>>>
>>  I log on as local system account but i'm using the service to launch an
>> application with a gui so i enabled "allow service to interact with
>> desktop".
>>
>
> Doubt you can log in as a local system account.
>
> Anyhow, that'll work with XP only. Any contemporary windows
> version (Vista, Win7, ...) will refuse to display anything from
> the Session0. You usually need some sort of IPC between the service
> and GUI app in the user session.
>
>
>   And then i get an empty dos-console-window, which i want to minimize
>> automatically.
>>
>>
> Services are console applications by default.
> Sure you can use gui (hell, you can even modify the procrun.exe to
> behave like GUI app, if you know how to edit the exe's PE header),
> but then you'll loose stdout/stderr inside JVM.
>
> Like said, I'd suggest you review your design. Starting a GUI from
> the service is not how you do things.
>
>   So my design is not optimal/elegant but i have no idea how to do it
another way.
  My requirements are:
 1. My Application must start at system start (service starts automatically)
 2. Application must be able to recover from jvm crashes (service can be
restartet when terminated abnormally)
 3. must accept user input (allow service to interact with desktop)

 and it works for me, the only thing that's not the way i want it is the
dos-console showing.
 But it would very nice, if you can give me some hints, how to do it a
better way.

>
> Regards
> --
> ^TM
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [daemon]

Posted by Mladen Turk <mt...@apache.org>.
On 07/18/2011 09:21 AM, Hans Rupp wrote:
> 2011/7/15 Mladen Turk<mt...@apache.org>
>
>>>
>> There is no window if started as service.
>> Are you referring starting the procrun from user session?
>> Why would you wish to do that?
>>
>>
>>
>>   Thanks for your answer.
>   I log on as local system account but i'm using the service to launch an
> application with a gui so i enabled "allow service to interact with
> desktop".

Doubt you can log in as a local system account.

Anyhow, that'll work with XP only. Any contemporary windows
version (Vista, Win7, ...) will refuse to display anything from
the Session0. You usually need some sort of IPC between the service
and GUI app in the user session.

>   And then i get an empty dos-console-window, which i want to minimize
> automatically.
>

Services are console applications by default.
Sure you can use gui (hell, you can even modify the procrun.exe to
behave like GUI app, if you know how to edit the exe's PE header),
but then you'll loose stdout/stderr inside JVM.

Like said, I'd suggest you review your design. Starting a GUI from
the service is not how you do things.


Regards
-- 
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [daemon]

Posted by Hans Rupp <ha...@googlemail.com>.
2011/7/15 Mladen Turk <mt...@apache.org>

> On 07/15/2011 02:19 PM, Hans Rupp wrote:
>
>>
>> i have 2 questions about procrun (i’m using win xp).
>>
>>
>>
>> 1. is it possible to run a jar-file as service, so that at service start
>> the
>> standard jdk6 splashscreen is showing? I always get null from
>> getSplashScreen() when running as service, but when I start it from the
>>
>>
> No. Services don't have desktop. In theory it's possible
> but requires a huge pile of code and where it would be shown
> on system boot when there is no users log in?
>
>
>
>> 2.Is it possible to get rid of or at least minimize the dos-Window of
>> procrun?
>>
>>
> There is no window if started as service.
> Are you referring starting the procrun from user session?
> Why would you wish to do that?
>
>
> Regards
> --
> ^TM
>
>  Thanks for your answer.
 I log on as local system account but i'm using the service to launch an
application with a gui so i enabled "allow service to interact with
desktop".
 And then i get an empty dos-console-window, which i want to minimize
automatically.

> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [daemon]

Posted by Mladen Turk <mt...@apache.org>.
On 07/15/2011 02:19 PM, Hans Rupp wrote:
>
> i have 2 questions about procrun (i’m using win xp).
>
>
>
> 1. is it possible to run a jar-file as service, so that at service start the
> standard jdk6 splashscreen is showing? I always get null from
> getSplashScreen() when running as service, but when I start it from the
>

No. Services don't have desktop. In theory it's possible
but requires a huge pile of code and where it would be shown
on system boot when there is no users log in?

>
> 2.Is it possible to get rid of or at least minimize the dos-Window of
> procrun?
>

There is no window if started as service.
Are you referring starting the procrun from user session?
Why would you wish to do that?


Regards
-- 
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org