Running a deamonized app
cedricleroy opened this issue · 2 comments
I use a daemon to run my app (something like that), and it seems it is not really working.
I first tried to initiate stackimpact at the top of my core module as shown in the examples, but could not run my app as a service anymore as stackimpact was not deamonized along other stuff (makes sense). I then tried to initiate stackimpact in run(), but I don't get any data. I think stackimpact is not really designed to work like that, I would be curious if there is a way to make it work.
Env is Python 3.5.2, stackimpact v1.0.1
Would be happy to provide more details if needed.
I have been running into similar issues. The issue for me at least appears to be using stackimpact with any app that has a signal handler(most daemon apps do). I am regularly catching SIGALRM, which is preventing block_reporter from operating correctly I think.
I still get health stats, but the other features always report 0 for everything.
As an example of the signal handler collisions, this snippet will show the cadence of stackimpact's signals as time.sleep will wake on signal.
import stackimpact
import time
from datetime import datetime
def main():
agent = stackimpact.start(agent_key = 'xxxxx', app_name = 'signaltest')
while True:
for x in range(0, 100):
print(datetime.now())
time.sleep(5)
if __name__ == "__main__":
main()
@cedricleroy I've tried the daemon setup using the link and starting the agent in the run()
- it worked for me. Everything was reported as expected. I've then added more cpu intensive code as well as blocking calls, and that was also reported as it should. The only problem was stopping the daemon: there was a bug in the agent default signal overwriting for shutdown signals, which is now fixed in 1.0.2 (released). You can try adding debug = True
option, may be there are some errors.
@redNixon the agent takes over SIGALRM and SIGPROF and uses them all the time. What you can do for the moment is disable profilers, which conflict. Blocking call profiler uses SIGALRM, which can be disabled by passing block_profiler_disabled = True
as startup option. Other options are: cpu_profiler_disabled = True
(signal SIGPROF), allocation_profiler_disabled = True
(signal SIGUSR2, however, this one is handled nicely, by filtering out only related signals and forwarding the rest).
Regarding the time.sleep()
, it conflicts with SIGALRM on Python 2, but not on Python 3. We're trying to fix this for Python 2.