How to run web2py's scheduler as uwsgi's mule?

133 views
Skip to first unread message

Zbigniew Pomianowski

unread,
Sep 10, 2014, 6:35:25 AM9/10/14
to web...@googlegroups.com
Hi, I tried this apporach:
<uwsgi>
  <uid>web2py</uid>
  <gid>web2py</gid>
  <virtualenv>/home/user/webapps/web2py/env</virtualenv>
  <http>:25903</http>

  <pythonpath>/home/user/webapps/web2py/web2py</pythonpath>
  <module>wsgihandler</module>
  <socket>/tmp/web2py.sock</socket>
  <master/>
  <cheaper-algo>spare</cheaper-algo>
  <cheaper>1</cheaper>
  <workers>6</workers>
  <mule>run_scheduler.py</mule>
  <cheaper-step>1</cheaper-step>
  <cheaper-rss-limit-soft>402653184</cheaper-rss-limit-soft>
  <harakiri>30</harakiri>
  <reload-mercy>8</reload-mercy>
  <max-requests>2000</max-requests>
  <limit-as>512</limit-as>
  <buffer-size>2048</buffer-size>
  <post-buffering>1024</post-buffering>
  <reload-on-as>256</reload-on-as>
  <reload-on-rss>192</reload-on-rss>
  <memory-report/>
  <disable-logging/>
  <daemonize>uwsgi.log</daemonize>
</uwsgi>

run_scheduler.py (in web2py dir):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys

# Note the app name is hardcoded!
APPLICATION = 'myapp'

if '__file__' in globals():
    path = os.path.dirname(os.path.abspath(__file__))
    os.chdir(path)
else:
    path = os.getcwd() # Seems necessary for py2exe

sys.path = [path]+[p for p in sys.path if not p==path]

import gluon.widget
from gluon.shell import run

# Start Web2py Scheduler
if __name__ == '__main__':
    run(APPLICATION,True,True,None,False,"from gluon import current; current._scheduler.loop()")


When I run scheduler manually from a console (with venv) - it is ok. But i need to pass -p 25903. When I try a mule - it does not work.
I use webfaction server. The problem is that when I launch the scheduler from console it runs until the ssh session is active.

Niphlod

unread,
Sep 10, 2014, 7:46:53 AM9/10/14
to web...@googlegroups.com
I don't think webfaction allows you to have a resident process active beside the web-serving one.

Zbigniew Pomianowski

unread,
Sep 10, 2014, 9:00:11 AM9/10/14
to web...@googlegroups.com
I think I can have a resident process. When I make a simple loop script it is executed by mule. It is strange to me I need to pass "-p 25903" to have active worker that performs the queued tasks.

Niphlod

unread,
Sep 10, 2014, 11:58:30 AM9/10/14
to web...@googlegroups.com
if started, scheduler doesn't quit itself. Where are you needing to pass "-p 25903" ?

BTW: in that script, importing gluon.widget is superflous.
Reply all
Reply to author
Forward
0 new messages