Events for startup/shutdown?

162 views
Skip to first unread message

Andreas Jung

unread,
Jan 25, 2013, 2:11:12 AM1/25/13
to pylons-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,

any chance to capture the startup and shutdown of a Pyramid service?
I want to capture start/stop of Pyramid as event in our central
monitoring service.

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJRAjAQAAoJEADcfz7u4AZjWZoLwK/2BL87GEnxLvf3o4o9lCjc
u1TL1koYaTKR9fA1NAKh/jaRM83s6d7qrFXhQVikG1TbSk0a0ZMoyzVPDE3GXkZn
SEA1WAtHa9qRvHg0lDX4VFT/uDY2nCS6DotLnWVFY38ezI6RMbI5objqtcSs6wbX
jFuIp26hXD2z6AGPRbwq5J06jEkfkBsu1aCtgRNsdmfgLY084tSzCh9duwbV6eD6
BgJzTnzHLUfGreqt0Nibxuj/Nqa7S6ko8s6fxqwPnN0Fy3d2Yej3Z/NxjCOEwKwb
z4qww7tYDUdFNDN0QOXK+EDFT0akJlOV6EUdYs0eHWBsjaVZz/lUucZTOv9PcwMg
kKEHBzNgLo6bH8OcIaVFCngmARJeO4sM8A6mL2VmYbYD//+0dnVaMm3v1++q6BRL
fX87E+tzW2ZIhtxzJ4sdBlF+y4EkGIvs8PCOegO0EdlOXU5V/59wPXrizDGyUFK2
xmQ45YwFkS/jR1tYWkwl/we8LBLMsXk=
=rD7D
-----END PGP SIGNATURE-----
lists.vcf

Michael Merickel

unread,
Jan 25, 2013, 2:32:22 AM1/25/13
to Pylons
WSGI is a pure request-level protocol, it does not handle or care how it is served. As a result, a WSGI app (such as Pyramid) has no concept of when the service begins or ends. The closest you'll get to this is a startup hook such as your main() or ApplicationCreated for tracking the start. The other option is to hope that your server has hooks that can be used to track this. Finally, process state can be monitored externally via supervisor or some other process monitor.



--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Andreas Jung

unread,
Jan 25, 2013, 3:45:24 AM1/25/13
to pylons-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Michael Merickel wrote:
> WSGI is a pure request-level protocol, it does not handle or care how
> it is served. As a result, a WSGI app (such as Pyramid) has no
> concept of when the service begins or ends.

As Zope veteran, I know :-) I am asking about the backend, not the WSGI
level.

> The closest you'll get to this is a startup hook such as your main()
> or ApplicationCreated for tracking the start.

ACK for the startup

> The other option is to hope that your server has hooks that can be
> used to track this. Finally, process state can be monitored
> externally via supervisor or some other process monitor.

I am still missing for the shutdown phase. Supervisord...is an option
but I want to have something in my app. I tried using an atexit handler
but it is never executed.

- -aj

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJRAkYjAAoJEADcfz7u4AZjVT8LwJHlrJygPxj/Ro3UOS0W6BNO
aJM+4T0Eg9hyMxhBOiHgBhY3rmJlRQYWvpH8zvlFMLbXaTU4bT+Ez2xxIiNhJDRx
6RMt3+YiVOC5Ab703tG9KGSIDELEHtJicXE6RVBDEHWD7wFFXOBD/lfDgTbe8Blq
ZBgP3QVXHJL5sRkaYbRnUIpNbWnoXh5mYsRVHaZgiSilG7LReS6Ru+njSQ2y+4oy
s70GtNqFj/edm+coJd1dLxbyZxvo98gXLyNpxN4ZpYCkCDEtq/7glx2bEGgJLieV
pVNs6byRRQeJIvsUd9tNOpkBVPLAXM98pHRfvkSXCqV4sGJz9auPzxacu8kr2On5
w3jAQ970jrer+avgt3S7AhQRDCeq+Ww+m2OPuRJQwmPDgs2RiIUYg6XoP1MDm0ds
kU1UX98a4qWkmV5CXGLGProii6edQpE2GFOooZi6jZcNtvrJrVK7E7RXRZlfnu5q
xLllNy/mMApsKaPqkfbyoroPqg6GrJc=
=FSG7
-----END PGP SIGNATURE-----
lists.vcf

Luis Aguirre

unread,
Jan 25, 2013, 5:41:15 AM1/25/13
to pylons-...@googlegroups.com
Hi Andreas,

You may capture signals from python to get the shutdown.  Using SIGINT is the most common way to stop an application gracefully.  You may see an example here: http://stackoverflow.com/questions/1112343/how-do-i-capture-sigint-in-python .

Best regards,

Luis Aguirre

2013/1/25 Andreas Jung <li...@zopyx.com>
-----END PGP SIGNATURE-----

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.

To post to this group, send email to pylons-...@googlegroups.com.

Andreas Jung

unread,
Jan 25, 2013, 10:14:46 AM1/25/13
to pylons-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Problem solved for now. My atexit.register() handler is now called
when I used pserve without --reload option. Using --reload cause
the handler being ignored.

Andreas

Luis Aguirre wrote:
> Hi Andreas,
>
> You may capture signals from python to get the shutdown. Using
> SIGINT is the most common way to stop an application gracefully. You
> may see an example here:
> http://stackoverflow.com/questions/1112343/how-do-i-capture-sigint-in-python
> .
>
> Best regards,
>
> Luis Aguirre
>
> 2013/1/25 Andreas Jung <li...@zopyx.com <mailto:li...@zopyx.com>>
>
>
>
> Michael Merickel wrote:
>> WSGI is a pure request-level protocol, it does not handle or care
>> how it is served. As a result, a WSGI app (such as Pyramid) has no
>> concept of when the service begins or ends.
>
> As Zope veteran, I know :-) I am asking about the backend, not the
> WSGI level.
>
>> The closest you'll get to this is a startup hook such as your
>> main() or ApplicationCreated for tracking the start.
>
> ACK for the startup
>
>> The other option is to hope that your server has hooks that can be
>> used to track this. Finally, process state can be monitored
>> externally via supervisor or some other process monitor.
>
> I am still missing for the shutdown phase. Supervisord...is an
> option but I want to have something in my app. I tried using an
> atexit handler but it is never executed.
>
> -aj
>
>
> -- You received this message because you are subscribed to the
> Google Groups "pylons-discuss" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
> pylons-discus...@googlegroups.com
> <mailto:pylons-discuss%2Bunsu...@googlegroups.com>. To post to
> this group, send email to pylons-...@googlegroups.com
> <mailto:pylons-...@googlegroups.com>. Visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en. For more
> options, visit https://groups.google.com/groups/opt_out.
>
>
>
> -- You received this message because you are subscribed to the
> Google Groups "pylons-discuss" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
> pylons-discus...@googlegroups.com. To post to this group,
> send email to pylons-...@googlegroups.com. Visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en. For more
> options, visit https://groups.google.com/groups/opt_out.
>
>

- --
ZOPYX Limited | Python | Zope | Plone | MongoDB
Hundskapfklinge 33 | Consulting & Development
D-72074 T�bingen | Electronic Publishing Solutions
www.zopyx.com | Scalable Web Solutions
- --------------------------------------------------
Produce & Publish - www.produce-and-publish.com


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJRAqFlAAoJEADcfz7u4AZj/qULwKNYlF/cTnOPmw78KZOX4Hap
t6EJH2aGFbqoMcsw8WOvAkyiqrT0VHDJBxYcUbOyhdeXY7lpB9S+GttG09wRuOdK
50+nu1LcchgsPL38ZHCrgJpHGagPDlKThH5SaUuI1akVq7EZwCfoTFGOGJWWuxcN
wplfQqFyHF+889ArSnhUwgOs2tCkaUMO5N7569TsU2/3TYv1NhajIop3Maw95hUu
9ygovVHfNhCMIXDe4B4A4GfmdLADbnOVUOoEVy+SkN3D3RvyGISXNV9NwKHa9B1k
zG3G2/ibmcwEmMVCOfIVZY4p19XrP81iZQ2mjPp8j/B9KNhmT4c1x9mE8gu3wAr8
E0yyc2gkrJh1Ol8p/yoEOtTNBqw06x7YBMU1RhI/bmjwWVI7VaMXQStqU7MPXUen
IJ5p4xuCb8Ui559vQd23q/3Pe26MK6jnMGOpftzVEh+CJQwz9TlwrAcqAaBkOZpn
kGkM95PC4NrZ/apsH4GrLVFe64dcapg=
=9h/i
-----END PGP SIGNATURE-----
lists.vcf
Reply all
Reply to author
Forward
0 new messages