cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Cary Lewis
I am using cygrunsrv to install a windows service that creates an ssh tunnel.

I have configured the service to auto-restart on failures using the
windows 7 services.msc tool.

If the ssh program exists, or is killed, cygrunsrv gracefully exits,
and the windows auto-restart logic is not invoked.

Is there a way to get the auto-restart logic to work?

Thank you.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Corinna Vinschen-2
On Jan 26 11:14, Cary Lewis wrote:
> I am using cygrunsrv to install a windows service that creates an ssh tunnel.
>
> I have configured the service to auto-restart on failures using the
> windows 7 services.msc tool.
>
> If the ssh program exists, or is killed, cygrunsrv gracefully exits,
> and the windows auto-restart logic is not invoked.
>
> Is there a way to get the auto-restart logic to work?

Try the cygrunsrv option --neverexits.  If this option is set, the
service exits without notifying Windows.  SCM thinks the service has
exited prematurely and restarts it, if auto-restart has been configured.


HTH,
Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Kizito Porta Balanyà
2015-01-27 10:09 GMT+01:00 Corinna Vinschen <[hidden email]>:
> On Jan 26 11:14, Cary Lewis wrote:
>> I am using cygrunsrv to install a windows service that creates an ssh tunnel.

>
>> I have configured the service to auto-restart on failures using the
>> windows 7 services.msc tool.
>>
>> If the ssh program exists, or is killed, cygrunsrv gracefully exits,
>> and the windows auto-restart logic is not invoked.

>> Is there a way to get the auto-restart logic to work?

I'm doing it with monit compiled in cygwin (works most of the features).
I have create some wrappers scripts that does the job.

Tell me if you need something.

Regards.

>
> Try the cygrunsrv option --neverexits.  If this option is set, the
> service exits without notifying Windows.  SCM thinks the service has
> exited prematurely and restarts it, if auto-restart has been configured.
>
>
> HTH,
> Corinna
>
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Maintainer                 cygwin AT cygwin DOT com
> Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Cary Lewis
In reply to this post by Corinna Vinschen-2
Corinna, thanks for the tip

--neverexits works, but not if the program that cygrunsrv starts is
stopped with a kill -9 signal. Perhaps the -9 signal propagates to the
cygrunsrv.exe program?

I will investigate monit.

On Tue, Jan 27, 2015 at 4:09 AM, Corinna Vinschen
<[hidden email]> wrote:

> On Jan 26 11:14, Cary Lewis wrote:
>> I am using cygrunsrv to install a windows service that creates an ssh tunnel.
>>
>> I have configured the service to auto-restart on failures using the
>> windows 7 services.msc tool.
>>
>> If the ssh program exists, or is killed, cygrunsrv gracefully exits,
>> and the windows auto-restart logic is not invoked.
>>
>> Is there a way to get the auto-restart logic to work?
>
> Try the cygrunsrv option --neverexits.  If this option is set, the
> service exits without notifying Windows.  SCM thinks the service has
> exited prematurely and restarts it, if auto-restart has been configured.
>
>
> HTH,
> Corinna
>
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Maintainer                 cygwin AT cygwin DOT com
> Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Corinna Vinschen-2
On Jan 27 15:02, Cary Lewis wrote:

> On Tue, Jan 27, 2015 at 4:09 AM, Corinna Vinschen
> <[hidden email]> wrote:
> > On Jan 26 11:14, Cary Lewis wrote:
> >> I am using cygrunsrv to install a windows service that creates an ssh tunnel.
> >>
> >> I have configured the service to auto-restart on failures using the
> >> windows 7 services.msc tool.
> >>
> >> If the ssh program exists, or is killed, cygrunsrv gracefully exits,
> >> and the windows auto-restart logic is not invoked.
> >>
> >> Is there a way to get the auto-restart logic to work?
> >
> > Try the cygrunsrv option --neverexits.  If this option is set, the
> > service exits without notifying Windows.  SCM thinks the service has
> > exited prematurely and restarts it, if auto-restart has been configured.
> >
>
> Corinna, thanks for the tip
>
> --neverexits works, but not if the program that cygrunsrv starts is
> stopped with a kill -9 signal. Perhaps the -9 signal propagates to the
> cygrunsrv.exe program?
Hmm, yes.  Cygrunsrv evaluates how the service process ended, and only
if it exited the neverexits logic comes into play.  If it ended due to
a signal, it does nothing.

This is unfortunate because it diminishes the usefulness of --neverexits.
I could patch cygrunsrv to do this:

  If the service exited due to a signal, and if that signal is not the
  defined termination or shutdown signal (default SIGTERM for both),
  and if --neverexits has been defined, then performas the neverexits
  action.

Does that sound ok?

The patch is simple and I could upload a new cygrunsrv today or tomorrow.


Thanks,
Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Corinna Vinschen-2
On Jan 28 11:18, Corinna Vinschen wrote:

> On Jan 27 15:02, Cary Lewis wrote:
> > On Tue, Jan 27, 2015 at 4:09 AM, Corinna Vinschen
> > --neverexits works, but not if the program that cygrunsrv starts is
> > stopped with a kill -9 signal. Perhaps the -9 signal propagates to the
> > cygrunsrv.exe program?
>
> Hmm, yes.  Cygrunsrv evaluates how the service process ended, and only
> if it exited the neverexits logic comes into play.  If it ended due to
> a signal, it does nothing.
>
> This is unfortunate because it diminishes the usefulness of --neverexits.
> I could patch cygrunsrv to do this:
>
>   If the service exited due to a signal, and if that signal is not the
>   defined termination or shutdown signal (default SIGTERM for both),
>   and if --neverexits has been defined, then performas the neverexits
>   action.
>
> Does that sound ok?
>
> The patch is simple and I could upload a new cygrunsrv today or tomorrow.
https://cygwin.com/ml/cygwin-announce/2015-01/msg00041.html


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Andrey Repin
In reply to this post by Corinna Vinschen-2
Greetings, Corinna Vinschen!

>> --neverexits works, but not if the program that cygrunsrv starts is
>> stopped with a kill -9 signal. Perhaps the -9 signal propagates to the
>> cygrunsrv.exe program?

> Hmm, yes.  Cygrunsrv evaluates how the service process ended, and only
> if it exited the neverexits logic comes into play.  If it ended due to
> a signal, it does nothing.

> This is unfortunate because it diminishes the usefulness of --neverexits.
> I could patch cygrunsrv to do this:

>   If the service exited due to a signal, and if that signal is not the
>   defined termination or shutdown signal (default SIGTERM for both),
>   and if --neverexits has been defined, then performas the neverexits
>   action.

> Does that sound ok?

For me, yes.

> The patch is simple and I could upload a new cygrunsrv today or tomorrow.


--
WBR,
Andrey Repin ([hidden email]) 28.01.2015, <15:40>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Kizito Porta Balanyà
In reply to this post by Corinna Vinschen-2
2015-01-28 12:55 GMT+01:00 Corinna Vinschen <[hidden email]>:

> On Jan 28 11:18, Corinna Vinschen wrote:
>> On Jan 27 15:02, Cary Lewis wrote:
>> > On Tue, Jan 27, 2015 at 4:09 AM, Corinna Vinschen
>> > --neverexits works, but not if the program that cygrunsrv starts is
>> > stopped with a kill -9 signal. Perhaps the -9 signal propagates to the
>> > cygrunsrv.exe program?
>>
>> Hmm, yes.  Cygrunsrv evaluates how the service process ended, and only
>> if it exited the neverexits logic comes into play.  If it ended due to
>> a signal, it does nothing.
>>
>> This is unfortunate because it diminishes the usefulness of --neverexits.
>> I could patch cygrunsrv to do this:
>>
>>   If the service exited due to a signal, and if that signal is not the
>>   defined termination or shutdown signal (default SIGTERM for both),
>>   and if --neverexits has been defined, then performas the neverexits
>>   action.
>>
>> Does that sound ok?

I would say that this should be the default behavior:

If the signal is SIGTERM and the service is configured to restart the
program, then restart the program.

So, --neverxits should be the default behaviour of cygrunsrv , so
--neverexists shouldn't exist as an option. :) But perhaps I'm wrong
and I don't understand completely the problem.

Thanks for your time.

>> The patch is simple and I could upload a new cygrunsrv today or tomorrow.
>
> https://cygwin.com/ml/cygwin-announce/2015-01/msg00041.html
>
>
> Corinna
>
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Maintainer                 cygwin AT cygwin DOT com
> Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Corinna Vinschen-2
On Jan 28 15:42, Kizito Porta Balanyà wrote:

> 2015-01-28 12:55 GMT+01:00 Corinna Vinschen <[hidden email]>:
> > On Jan 28 11:18, Corinna Vinschen wrote:
> >> On Jan 27 15:02, Cary Lewis wrote:
> >> > On Tue, Jan 27, 2015 at 4:09 AM, Corinna Vinschen
> >> > --neverexits works, but not if the program that cygrunsrv starts is
> >> > stopped with a kill -9 signal. Perhaps the -9 signal propagates to the
> >> > cygrunsrv.exe program?
> >>
> >> Hmm, yes.  Cygrunsrv evaluates how the service process ended, and only
> >> if it exited the neverexits logic comes into play.  If it ended due to
> >> a signal, it does nothing.
> >>
> >> This is unfortunate because it diminishes the usefulness of --neverexits.
> >> I could patch cygrunsrv to do this:
> >>
> >>   If the service exited due to a signal, and if that signal is not the
> >>   defined termination or shutdown signal (default SIGTERM for both),
> >>   and if --neverexits has been defined, then performas the neverexits
> >>   action.
> >>
> >> Does that sound ok?
>
> I would say that this should be the default behavior:
>
> If the signal is SIGTERM and the service is configured to restart the
> program, then restart the program.
No.  SIGTERM (rather: the defined termination signal) is send
explicitely from cygrunsrv to the service process to stop the service.
If this is handled like --neverexits, it would be impossible to stop a
service manually.  The neverexits case should only cover the cases of
exiting as a result of an unexpected signal (SIGSEGV, etc).

> So, --neverxits should be the default behaviour of cygrunsrv , so
> --neverexists shouldn't exist as an option. :) But perhaps I'm wrong
> and I don't understand completely the problem.

I disagree.  Automatic restart of services is not desired by default.
It's a per-service, administrators choice.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

BGINFO4X
2015-01-28 16:37 GMT+01:00 Corinna Vinschen <[hidden email]>:

> On Jan 28 15:42, Kizito Porta Balanyà wrote:
>> 2015-01-28 12:55 GMT+01:00 Corinna Vinschen <[hidden email]>:
>> > On Jan 28 11:18, Corinna Vinschen wrote:
>> >> On Jan 27 15:02, Cary Lewis wrote:
>> >> > On Tue, Jan 27, 2015 at 4:09 AM, Corinna Vinschen
>> >> > --neverexits works, but not if the program that cygrunsrv starts is
>> >> > stopped with a kill -9 signal. Perhaps the -9 signal propagates to the
>> >> > cygrunsrv.exe program?
>> >>
>> >> Hmm, yes.  Cygrunsrv evaluates how the service process ended, and only
>> >> if it exited the neverexits logic comes into play.  If it ended due to
>> >> a signal, it does nothing.
>> >>
>> >> This is unfortunate because it diminishes the usefulness of --neverexits.
>> >> I could patch cygrunsrv to do this:
>> >>
>> >>   If the service exited due to a signal, and if that signal is not the
>> >>   defined termination or shutdown signal (default SIGTERM for both),
>> >>   and if --neverexits has been defined, then performas the neverexits
>> >>   action.
>> >>
>> >> Does that sound ok?
>>
>> I would say that this should be the default behavior:
>>
>> If the signal is SIGTERM and the service is configured to restart the
>> program, then restart the program.
>
> No.  SIGTERM (rather: the defined termination signal) is send
> explicitely from cygrunsrv to the service process to stop the service.
> If this is handled like --neverexits, it would be impossible to stop a
> service manually.  The neverexits case should only cover the cases of
> exiting as a result of an unexpected signal (SIGSEGV, etc).

I explained it bad. English is not my "default" language. :)

What I mean is:

   - If the automatic restart of the service is defined by the
administrator, the service should restart by default.
   - So, It shouldn't be necessary to register the service with --neverexits.

    - But if the administrator defines the autorestart option, the
service should be aware of it.

I hope you understand me.

Thanks .


>
>> So, --neverxits should be the default behaviour of cygrunsrv , so
>> --neverexists shouldn't exist as an option. :) But perhaps I'm wrong
>> and I don't understand completely the problem.
>
> I disagree.  Automatic restart of services is not desired by default.
> It's a per-service, administrators choice.
>
>
> Corinna
>
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Maintainer                 cygwin AT cygwin DOT com
> Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Andrey Repin
Greetings, BGINFO4X!

>>> >> This is unfortunate because it diminishes the usefulness of --neverexits.
>>> >> I could patch cygrunsrv to do this:
>>> >>
>>> >>   If the service exited due to a signal, and if that signal is not the
>>> >>   defined termination or shutdown signal (default SIGTERM for both),
>>> >>   and if --neverexits has been defined, then performas the neverexits
>>> >>   action.
>>> >>
>>> >> Does that sound ok?
>>>
>>> I would say that this should be the default behavior:
>>>
>>> If the signal is SIGTERM and the service is configured to restart the
>>> program, then restart the program.
>>
>> No.  SIGTERM (rather: the defined termination signal) is send
>> explicitely from cygrunsrv to the service process to stop the service.
>> If this is handled like --neverexits, it would be impossible to stop a
>> service manually.  The neverexits case should only cover the cases of
>> exiting as a result of an unexpected signal (SIGSEGV, etc).

> I explained it bad. English is not my "default" language. :)

> What I mean is:

>    - If the automatic restart of the service is defined by the
> administrator, the service should restart by default.
>    - So, It shouldn't be necessary to register the service with --neverexits.

>     - But if the administrator defines the autorestart option, the
> service should be aware of it.

No. Autorestart is there to help recover from service failures, WHEN such
recovery is desired by the system administrator.
It has nothing to do with the nature of the service, neither require service
to be aware of it.


>>> So, --neverxits should be the default behaviour of cygrunsrv , so
>>> --neverexists shouldn't exist as an option. :) But perhaps I'm wrong
>>> and I don't understand completely the problem.
>>
>> I disagree.  Automatic restart of services is not desired by default.
>> It's a per-service, administrators choice.

I think I can explain it a little different.
If we view cygrunsrv as a wrapper(bridge) between Cygwin(POSIX) daemon and
Windows service infrastructure, all what is required from it (beside
environment initialization) is to convert Windows control messages to
appropriate POSIX signals.
And, conversely, appropriately react to POSIX signals when service is
terminating by itself.
I'm not very familiar with passing signals back to called process, but if
cygrunsrv can distinguish graceful termination of controlled daemon from
abnormal shutdown, the "--neverexits" switch become redundant in case of
correct signal mapping.


--
WBR,
Andrey Repin ([hidden email]) 28.01.2015, <20:36>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Corinna Vinschen-2
In reply to this post by BGINFO4X
On Jan 28 16:58, BGINFO4X wrote:

> 2015-01-28 16:37 GMT+01:00 Corinna Vinschen <[hidden email]>:
> > On Jan 28 15:42, Kizito Porta Balanyà wrote:
> >> 2015-01-28 12:55 GMT+01:00 Corinna Vinschen <[hidden email]>:
> >> >> I could patch cygrunsrv to do this:
> >> >>
> >> >>   If the service exited due to a signal, and if that signal is not the
> >> >>   defined termination or shutdown signal (default SIGTERM for both),
> >> >>   and if --neverexits has been defined, then performas the neverexits
> >> >>   action.
> >> >>
> >> >> Does that sound ok?
> >>
> >> I would say that this should be the default behavior:
> >>
> >> If the signal is SIGTERM and the service is configured to restart the
> >> program, then restart the program.
> >
> > No.  SIGTERM (rather: the defined termination signal) is send
> > explicitely from cygrunsrv to the service process to stop the service.
> > If this is handled like --neverexits, it would be impossible to stop a
> > service manually.  The neverexits case should only cover the cases of
> > exiting as a result of an unexpected signal (SIGSEGV, etc).
>
> I explained it bad. English is not my "default" language. :)
>
> What I mean is:
>
>    - If the automatic restart of the service is defined by the
> administrator, the service should restart by default.
>    - So, It shouldn't be necessary to register the service with --neverexits.
Ok, I get your drift.  You're right, but this is a bit more complicated
than the simple tweak I applied to cygrunsrv today.

There's certainly room for improvement in cygrunsrv.  It's showing its
age, most of the code is unchanged since Cygwin still supported NT4.
It's not using the QueryServiceConfig2/ChangeServiceConfig2 functions at
all.

I wouldn't be too unhappy about a developer having fun to improve
cygrunsrv...


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Cary Lewis
In reply to this post by Corinna Vinschen-2
That sounds like a plan, thanks Corinna.

Do we need test how the service (program that cygrunsrv is running)
exited? If --neverexits is present, it shouldn't care how it exited,
it should just pass the fact that it exited unplanned to the SCM so
that the recovery actions take place.

It's only if cygrunsrv is the one that causes the 'service' to exit
that the --neverexists shouldn't be considered.

Does that make sense?

On Wed, Jan 28, 2015 at 5:18 AM, Corinna Vinschen
<[hidden email]> wrote:

> On Jan 27 15:02, Cary Lewis wrote:
>> On Tue, Jan 27, 2015 at 4:09 AM, Corinna Vinschen
>> <[hidden email]> wrote:
>> > On Jan 26 11:14, Cary Lewis wrote:
>> >> I am using cygrunsrv to install a windows service that creates an ssh tunnel.
>> >>
>> >> I have configured the service to auto-restart on failures using the
>> >> windows 7 services.msc tool.
>> >>
>> >> If the ssh program exists, or is killed, cygrunsrv gracefully exits,
>> >> and the windows auto-restart logic is not invoked.
>> >>
>> >> Is there a way to get the auto-restart logic to work?
>> >
>> > Try the cygrunsrv option --neverexits.  If this option is set, the
>> > service exits without notifying Windows.  SCM thinks the service has
>> > exited prematurely and restarts it, if auto-restart has been configured.
>> >
>>
>> Corinna, thanks for the tip
>>
>> --neverexits works, but not if the program that cygrunsrv starts is
>> stopped with a kill -9 signal. Perhaps the -9 signal propagates to the
>> cygrunsrv.exe program?
>
> Hmm, yes.  Cygrunsrv evaluates how the service process ended, and only
> if it exited the neverexits logic comes into play.  If it ended due to
> a signal, it does nothing.
>
> This is unfortunate because it diminishes the usefulness of --neverexits.
> I could patch cygrunsrv to do this:
>
>   If the service exited due to a signal, and if that signal is not the
>   defined termination or shutdown signal (default SIGTERM for both),
>   and if --neverexits has been defined, then performas the neverexits
>   action.
>
> Does that sound ok?
>
> The patch is simple and I could upload a new cygrunsrv today or tomorrow.
>
>
> Thanks,
> Corinna
>
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Maintainer                 cygwin AT cygwin DOT com
> Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Kizito Porta Balanyà
In reply to this post by Corinna Vinschen-2
2015-01-28 21:43 GMT+01:00 Corinna Vinschen <[hidden email]>:

> On Jan 28 16:58, BGINFO4X wrote:
>> 2015-01-28 16:37 GMT+01:00 Corinna Vinschen <[hidden email]>:
>> > On Jan 28 15:42, Kizito Porta Balanyà wrote:
>> >> 2015-01-28 12:55 GMT+01:00 Corinna Vinschen <[hidden email]>:
>> >> >> I could patch cygrunsrv to do this:
>> >> >>
>> >> >>   If the service exited due to a signal, and if that signal is not the
>> >> >>   defined termination or shutdown signal (default SIGTERM for both),
>> >> >>   and if --neverexits has been defined, then performas the neverexits
>> >> >>   action.
>> >> >>
>> >> >> Does that sound ok?
>> >>
>> >> I would say that this should be the default behavior:
>> >>
>> >> If the signal is SIGTERM and the service is configured to restart the
>> >> program, then restart the program.
>> >
>> > No.  SIGTERM (rather: the defined termination signal) is send
>> > explicitely from cygrunsrv to the service process to stop the service.
>> > If this is handled like --neverexits, it would be impossible to stop a
>> > service manually.  The neverexits case should only cover the cases of
>> > exiting as a result of an unexpected signal (SIGSEGV, etc).
>>
>> I explained it bad. English is not my "default" language. :)
>>
>> What I mean is:
>>
>>    - If the automatic restart of the service is defined by the
>> administrator, the service should restart by default.
>>    - So, It shouldn't be necessary to register the service with --neverexits.
>
> Ok, I get your drift.  You're right, but this is a bit more complicated
> than the simple tweak I applied to cygrunsrv today.
>
> There's certainly room for improvement in cygrunsrv.  It's showing its
> age, most of the code is unchanged since Cygwin still supported NT4.
> It's not using the QueryServiceConfig2/ChangeServiceConfig2 functions at
> all.
>
> I wouldn't be too unhappy about a developer having fun to improve
> cygrunsrv...

Hello, I can't develop it. I don't have the level. But ...

Perhaps the author of nssm can do it (http://nssm.cc/). I could send
an email to him ... for example .....

Or perhaps there is code there (nssm is public doamin) that can be
useful for cygrunsrv .

Note: nssm is a windows program very similar to cygrunsrv.

"nssm is a service helper which doesn't suck. srvany and other service
helper programs suck because they don't handle failure of the
application running as a service. If you use such a program you may
see a service listed as started when in fact the application has died.
nssm monitors the running service and will restart it if it dies. With
nssm you know that if a service says it's running, it really is.
Alternatively, if your application is well-behaved you can configure
nssm to absolve all responsibility for restarting it and let Windows
take care of recovery actions.

nssm logs its progress to the system Event Log so you can get some
idea of why an application isn't behaving as it should.

nssm also features a graphical service installation and removal
facility. Prior to version 2.19 it did suck. Now it's quite a bit
better."


Regards.
>
> Corinna
>
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Maintainer                 cygwin AT cygwin DOT com
> Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Corinna Vinschen-2
On Jan 29 10:11, Kizito Porta Balanyà wrote:

> 2015-01-28 21:43 GMT+01:00 Corinna Vinschen <[hidden email]>:
> > There's certainly room for improvement in cygrunsrv.  It's showing its
> > age, most of the code is unchanged since Cygwin still supported NT4.
> > It's not using the QueryServiceConfig2/ChangeServiceConfig2 functions at
> > all.
> >
> > I wouldn't be too unhappy about a developer having fun to improve
> > cygrunsrv...
>
> Hello, I can't develop it. I don't have the level. But ...
>
> Perhaps the author of nssm can do it (http://nssm.cc/). I could send
> an email to him ... for example .....
Thanks, but that doesn't make much sense, I think.  He's having his own
project so why should he have fun to work on cygrunsrv?

I'm rather looking for people using and (hopefully) liking Cygwin which
have a bit of developer experience and a bit of spare time to hack away
on stuff.  Cygwrunsrv, Setup, Cygwin itself, there's a lot of code and
a lot of developer niches in which to do something helpful.

Cygrunsrv is a fairly small project, for instance, and it should be
pretty easy to understand and it might be a good starting point for
somebody interested in helping an open source project along.

If nobody's beats me to it, I will certainly work on the cygrunsrv thingy
which triggered this discussion in the next couple of months.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: cygrunsrv - services enters stopped state if underlying program exits or is killed - doesn't auto restart

Corinna Vinschen-2
In reply to this post by Cary Lewis
Please, https://cygwin.com/acronyms/#TOFU
Thank you.

On Jan 28 17:38, Cary Lewis wrote:

> On Wed, Jan 28, 2015 at 5:18 AM, Corinna Vinschen
> <[hidden email]> wrote:
> > On Jan 27 15:02, Cary Lewis wrote:
> >> On Tue, Jan 27, 2015 at 4:09 AM, Corinna Vinschen
> >> <[hidden email]> wrote:
> >> --neverexits works, but not if the program that cygrunsrv starts is
> >> stopped with a kill -9 signal. Perhaps the -9 signal propagates to
> >> the cygrunsrv.exe program?
> >
> > Hmm, yes.  Cygrunsrv evaluates how the service process ended, and
> > only if it exited the neverexits logic comes into play.  If it ended
> > due to a signal, it does nothing.
> >
> > This is unfortunate because it diminishes the usefulness of
> > --neverexits.  I could patch cygrunsrv to do this:
> >
> >   If the service exited due to a signal, and if that signal is not
> >   the defined termination or shutdown signal (default SIGTERM for
> >   both), and if --neverexits has been defined, then performas the
> >   neverexits action.
> >
> > Does that sound ok?
> >
> > The patch is simple and I could upload a new cygrunsrv today or
> > tomorrow.
>
> That sounds like a plan, thanks Corinna.
>
> Do we need test how the service (program that cygrunsrv is running)
> exited? If --neverexits is present, it shouldn't care how it exited,
> it should just pass the fact that it exited unplanned to the SCM so
> that the recovery actions take place.
This is what happens now in 1.62-1 when it exited due to an unplanned
signal.

> It's only if cygrunsrv is the one that causes the 'service' to exit
> that the --neverexists shouldn't be considered.

That's when the termination or shutdown signal arrives.  Please give
cygrunsrv-1.62-1 a try.


Thanks,
Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (836 bytes) Download Attachment