|
List Info
Thread: win32/service... still with problems.
|
|
| win32/service... still with problems. |

|
2006-05-22 20:04:46 |
> -----Original Message-----
> From: win32utils-devel-bounces rubyforge.org
> [mailto:win32utils-devel-bounces rubyforge.org] On Behalf Of
> Luis Lavena
> Sent: Monday, May 22, 2006 12:38 PM
> To: Development and ideas for win32utils projects
> Subject: Re: [Win32utils-devel] win32/service... still
with problems.
>
>
> On 5/22/06, Berger, Daniel <Daniel.Berger qwest.com> wrote:
> > I didn't see it because your 'log' method was
defined
> outside of your
> > daemon class. In fact, your script works just
fine once you move
> > those methods within the Daemon class itself.
Attached is
> the script
> > I'm using. Here was the output:
> >
> > 2006-05-22 11:58:09 - ** Dead Simple Service
starting...
> >
> > 2006-05-22 11:58:11 - ** Done initialization.
> >
> > 2006-05-22 11:58:11 - Entering Service Main
> > do nothing!
> >
> > 2006-05-22 11:58:49 - Leaving Service Main
> >
> > (I added some spaces there since Outlook is
joining them
> into a single
> > string for some reason).
> >
> > Hope that helps.
> >
> > Dan
>
> Daniel, you tried more than 1 start/stop cycles?
Yes. I ran a series of start/stops as fast as my little
fingers would
let me. No problem.
> In the first run, everything worked ok, but several
tries
> after it, showed that it works "sometimes"
and other don't.
> (no matter if you left the service running for 1 second
or 10 minutes)
When you say it didn't work, do you mean that the the
service_main or
service_stop hooks weren't called? Or some other error?
<snip>
> If you see the attached version, service_stop will try
to
> raise the Interrupt exception so the runner thread gets
terminated.
Ok, I see the same behavior you mention - the service_stop
handler
doesn't get executed for some reason. I think we're back
to the thread
issues that Heesob mentioned in a previous post about this.
Heesob, care to weigh in?
Dan
This communication is the property of Qwest and may contain
confidential or
privileged information. Unauthorized use of this
communication is strictly
prohibited and may be unlawful. If you have received this
communication
in error, please immediately notify the sender by reply
e-mail and destroy
all copies of the communication and any attachments.
_______________________________________________
win32utils-devel mailing list
win32utils-devel rubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel
|
|
| win32/service... still with problems. |

|
2006-05-22 20:32:26 |
On 5/22/06, Berger, Daniel <Daniel.Berger qwest.com> wrote:
[...]
> >
> > Daniel, you tried more than 1 start/stop cycles?
>
> Yes. I ran a series of start/stops as fast as my
little fingers would
> let me. No problem.
>
Me too, I though was my pc, so dumped my p3 800mhz 512mb for
a p4,
3.0ghz, 1gb... same results.
> > In the first run, everything worked ok, but
several tries
> > after it, showed that it works
"sometimes" and other don't.
> > (no matter if you left the service running for 1
second or 10 minutes)
>
> When you say it didn't work, do you mean that the the
service_main or
> service_stop hooks weren't called? Or some other
error?
the service_stop hook is called, but the code in there is no
executed,
to the point the service stop responding and service manager
report it
that the pipe has ended or an exception ocurred.
> > If you see the attached version, service_stop will
try to
> > raise the Interrupt exception so the runner thread
gets terminated.
>
> Ok, I see the same behavior you mention - the
service_stop handler
> doesn't get executed for some reason. I think we're
back to the thread
> issues that Heesob mentioned in a previous post about
this.
>
> Heesob, care to weigh in?
>
I didn't get the Heesob reply about this, maybe thats why I
keep
asking the same :-P
On my freebasic (please, don't think freebasic as old
basica, is more
powerful than that, closer to c, but with basic syntax).
Anyway, on my framework, I solved this problem executing my
Main
function (which will be service_main in the ruby side) in
another
thread and wait for it to terminate until I destroy the
events.
Also, wouldn't be more correct report to the service
manager that
SERVICE_STOP_PENDING (is stopping) before calling
service_stop? in
service.c:78-83 thre is executed from EventHookHash prior
reporting
the Service Manager that we received the stop signal and we
are
stopping.
In service.c:114, dwControlCode is evaluated after setting
the
ServiceState, and if it was CONTROL_STOP, we set the Stop
event,
something that exit service_main prematurely.
I don't think service.c could be implemented as pure ruby
(due
required native threads)... or not?
Please excuse my english (again), I try to explain better I
could, but
is not easy due: complexity of the topic, and the
self-learned nature
of the language.
Regards,
--
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard
effort,
which is the price which all of us must pay to achieve any
goal that
is worthwhile.
Vince Lombardi
_______________________________________________
win32utils-devel mailing list
win32utils-devel rubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel
|
|
| win32/service... still with problems. |

|
2006-05-22 23:50:53 |
Hi,
2006/5/23, Luis Lavena <luislavena gmail.com>:
> On 5/22/06, Berger, Daniel <Daniel.Berger qwest.com> wrote:
> [...]
> > >
> > > Daniel, you tried more than 1 start/stop
cycles?
> >
> > Yes. I ran a series of start/stops as fast as my
little fingers would
> > let me. No problem.
> >
> Me too, I though was my pc, so dumped my p3 800mhz
512mb for a p4,
> 3.0ghz, 1gb... same results.
>
> > > In the first run, everything worked ok, but
several tries
> > > after it, showed that it works
"sometimes" and other don't.
> > > (no matter if you left the service running
for 1 second or 10 minutes)
> >
> > When you say it didn't work, do you mean that the
the service_main or
> > service_stop hooks weren't called? Or some other
error?
>
> the service_stop hook is called, but the code in there
is no executed,
> to the point the service stop responding and service
manager report it
> that the pipe has ended or an exception ocurred.
>
> > > If you see the attached version, service_stop
will try to
> > > raise the Interrupt exception so the runner
thread gets terminated.
> >
> > Ok, I see the same behavior you mention - the
service_stop handler
> > doesn't get executed for some reason. I think
we're back to the thread
> > issues that Heesob mentioned in a previous post
about this.
> >
> > Heesob, care to weigh in?
> >
> I didn't get the Heesob reply about this, maybe thats
why I keep
> asking the same :-P
>
I repeat the last answer.
As you know,the win32-service is multithreaded application.
But, Ruby's sleep or select is not compatible with the
Thread of Windows.
While executing sleep or select in ruby code,the other
thread cannot
do anything.
To workaround this stopping problem,
1. Use loop of short sleep insthead of long sleep.
ex) 10.times { sleep 1 } instead of sleep 10
2. Use nonblocking IO and socket.
> On my freebasic (please, don't think freebasic as old
basica, is more
> powerful than that, closer to c, but with basic
syntax).
>
> Anyway, on my framework, I solved this problem
executing my Main
> function (which will be service_main in the ruby side)
in another
> thread and wait for it to terminate until I destroy the
events.
>
> Also, wouldn't be more correct report to the service
manager that
> SERVICE_STOP_PENDING (is stopping) before calling
service_stop? in
> service.c:78-83 thre is executed from EventHookHash
prior reporting
> the Service Manager that we received the stop signal
and we are
> stopping.
>
> In service.c:114, dwControlCode is evaluated after
setting the
> ServiceState, and if it was CONTROL_STOP, we set the
Stop event,
> something that exit service_main prematurely.
>
> I don't think service.c could be implemented as pure
ruby (due
> required native threads)... or not?
>
I tried but it would't work for now.
The workaround of stopping problem for now is separate
service control
process and working process.
In service_main, use system,fork or something create another
ruby
program for working process and send kill to it when stop
requested.
> Please excuse my english (again), I try to explain
better I could, but
> is not easy due: complexity of the topic, and the
self-learned nature
> of the language.
>
> Regards,
>
> --
> Luis Lavena
> Multimedia systems
> -
Regards,
Park Heesob
_______________________________________________
win32utils-devel mailing list
win32utils-devel rubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel
|
|
| win32/service... still with problems. |

|
2006-05-23 12:28:08 |
On 5/22/06, Heesob Park <phasis gmail.com> wrote:
> As you know,the win32-service is multithreaded
application.
> But, Ruby's sleep or select is not compatible with the
Thread of Windows.
> While executing sleep or select in ruby code,the other
thread cannot
> do anything.
>
> To workaround this stopping problem,
>
> 1. Use loop of short sleep insthead of long sleep.
> ex) 10.times { sleep 1 } instead of sleep 10
>
> 2. Use nonblocking IO and socket.
>
Understand that, but wanted to "remark" that
anything that take more
than 1 seconds to cleanup in service_main get terminated, no
matter if
service_main finished or not.
> The workaround of stopping problem for now is separate
service control
> process and working process.
> In service_main, use system,fork or something create
another ruby
> program for working process and send kill to it when
stop requested.
>
That will create 2 ruby process, one for the service (which
will
depend of svchost.exe) and a child process...
If I send a kill signal, the child process will not cleanup
properly,
something we must avoid in a good coded application.
For that approach, using srvany uses less memory than
another ruby
process... (just loading the service.so and no other things
we use 6MB
of memory).
Anyway, long live to the threading model of Ruby! (better
yet, hate
Windows Threads).
Another workaround will be create a native (compiled) exe
that
redirect stdin/stdout of the childprocess and execute the
Cntrl-C to
finish it properly. I could do it with 30k exe and less than
1.5mb
footprint.
> Regards,
>
> Park Heesob
Thank you for the time you and Dan took answering my mails
and testing
the scripts.
Regards,
--
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard
effort,
which is the price which all of us must pay to achieve any
goal that
is worthwhile.
Vince Lombardi
_______________________________________________
win32utils-devel mailing list
win32utils-devel rubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel
|
|
[1-4]
|
|