unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.45k stars 689 forks source link

Creating alarms for segfaults #145

Closed prymitive closed 10 years ago

prymitive commented 11 years ago

I wanted to use alarm subsystem to notify me in case of any segfault, but log-alarm handles only single line at a time. Could we also have segfault-alarm = alarm_handler that would fire when any worker segfaults and pass whole backtrace to the alarm handler?

unbit commented 11 years ago

You can trigger alarms in your code with

void uwsgi_alarm_run(struct uwsgi_alarm_instance uai, char msg, size_t len);

to get a uwsgi_alarm_instance pointer you can use:

struct uwsgi_alarm_instance uwsgi_alarm_get_instance(char name);

where name is the name of the alarm instance

the log-alarm subsystem simply trigger that for every logline that matches. You can add more cases in which to put that

prymitive commented 11 years ago

Thanks, I'll try to implement alarms for segfaults and harakiri in few days.

unbit commented 11 years ago

Have you already started that ? I would like to clean the api a bit for making the triggering of alarms from processes other than the master easier.

prymitive commented 11 years ago

No and I won't have time for it this week, go ahead with those changes.

prymitive commented 11 years ago

Are those API changes done? I don't see any.

unbit commented 11 years ago

still not. Need to fix 3 areas in 1.9 before (ruby fibers, fastcgi and mongrel2 support). Hope to work on that tomorrow

prymitive commented 11 years ago

Ok, no rush, just let me know

unbit commented 11 years ago

Ok, the api function is ready:

uwsgi_alarm_trigger(char alarm_name, char message, size_t message_size);

you can call it in all of the processes (or from apps, using uwsgi.alarm(name, msg))

I do not know how you intend to map it to the SEGV handler, maybe you have to combine the whole backtrace output to a single memory buffer...

prymitive commented 11 years ago

I do not know how you intend to map it to the SEGV handler, maybe you have to combine the whole backtrace output to a single memory buffer...

I have no idea either, but not knowing before and knowing it once You're done is part of the fun ;)

prymitive commented 11 years ago

BTW it looks like I might have busy week so I don't know if I'll be able to look into it until next weekend

prymitive commented 11 years ago

Please review this patch It will break on each request since it will divide by zero (for testing).

./uwsgi --http :8080 --wsgi-file tests/staticfile.py --alarm "mailme cmd:mail -s 'uWSGI alarm' -r 'uwsgi@localhost' me@domain.com" --segfault-alarm mailme

and then just curl localhost:8000

prymitive commented 11 years ago

Any chance we could finish this one before 1.9?

unbit commented 11 years ago

yes for sure, i need to make a couple of corner-case-fixes and should be complete

prymitive commented 11 years ago

It would be real handy if we could push this forward in not so distant future.