from setproctitle import setproctitle, getproctitle
_proclabel = "thisapp"
if not getproctitle().startswith(_proclabel):
setproctitle(_proclabel + ' ' + getproctitle())This puts the label at the front, so I can do things like
17162 s000 S 0:00.15 thisapp processes
17163 s000 S 0:00.02 thisapp simulation_service
17164 s000 S 0:00.06 thisapp statehouse_service
17167 s000 S 0:00.08 thisapp serial_interface_service
17168 s000 S 0:00.01 thisapp email_service
17169 s000 S 0:00.05 thisapp periodic_serial_query_service
I want to also label the web2py process at startup. So far, the only way I've found is to include the setproctitle code in an app's 0.py model file and then have my startup script fetch the index page after web2py is up and running.
It would be nicer to be able to put it in script that runs once as web2py.py starts, but there doesn't seem to be a way to do that without the -R option which is recommended on for -S shell invocations of web2py.
I'd rather not hack web2py.py or one of the gluon modules. Is there a better way?
Thanks!
import os
import sys
path = os.path.dirname(os.path.abspath(__file__)) # alter to make sure we point toplevel web2py dir.
os.chdir(path)
sys.path = [path] + [p for p in sys.path if not p == path]
# important that this import is after the os.chdir
import gluon.widget
# Start Web2py (without cron service) !
#TODO fix up sys.args to match my use case
#TODO call setproctitle here
gluon.widget.start(cron=True)
So if I wrap all the above in a function, would I be able to launch it successfully with multiprocessing.Process? That would be a real help as I could then dispense with a top-level shell script that's now launching web2py separately from my other processes. And would the setproctitle() call give the desired result or would I need to push that down into gluon.widget?
Thanks!
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/zdVUnKgm1zQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/zdVUnKgm1zQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.