On Wednesday, February 24, 2016 at 4:57:43 PM UTC-8, Lucas Schreiber wrote: > > I have read the book. But it doesn't state where to actually write the > code snipes given. Both, the book and google is very fancy about explaining > how to start a scheduler by the console. But i literally do not see how i > can start the scheduler. >
<URL:http://web2py.com/books/default/chapter/29/04/the-core#Scheduler-Deployment> the -K option starts a process which runs the scheduler. You can use the -X option with it to only have 1 instance of Web2Py running, with the Rocket server providing the internet access. If you are using Apache or Nginx, I suppose you don't use -X, but I'm not quite graduated to that class yet. (in the command-line options section, <URL:http://web2py.com/books/default/chapter/29/04/the-core#Command-line-options> the -K is illustrated as "-K SCHEDULER", which might be confusing if you don't see that "SCHEDULER" is either the name of your app, a list of apps, or a list of app groups.) > If i write this into the controller, > > scheduler.queue_task( > task_1, > pargs=[], > pvars={}, > start_time=now, #datetime > stop_time = None, #datetime > timeout = 60, #seconds > prevent_drift=False, > period=60, #seconds > immediate=False, > repeats = 1 > ) > > it atleast creates the tables and populates one of the tables with an set > of records(scheduler_task) and does so whenever i call the function. But it > only works as long as the function is in the same controller. if the > function is in the modules, an error is returned. When i put this into the > model, it creates the tabels but does not populate any of them. > > some possible reasons why it does not run i have made up are: > -i'm queueing tasks but not creating a worker to work on them (but the > book doesnt state anywhere to create a worker. I think therefore this cant > be the solution) > This is the explanation. The -K option described at the above links is the key. > -the function isn't defined proper and the worker does not know what to do. > > This would probably result in an error being logged in the scheduler_run table which you can look at to debug. (I am, of course, familiar with that!) Good luck! /dps > > > Am Mittwoch, 24. Februar 2016 00:11:47 UTC+1 schrieb Lucas Schreiber: >> >> Hi there, >> while trying to understand how to use the scheduler, i found this post: >> https://groups.google.com/forum/#!topic/web2py/VCPZmSc0vLc >> >> In the Post, this code is writen: >> db.scheduler_task.insert(function_name='task1', >> task_name='task1', >> stop_time = now + timedelta(days=90000), >> repeats=0, >> period=10) >> g >> Where do i put this code? in the model? I think this was partly answered >> in the post, but i dont understand it. can someone explain this to me? >> >> Also, is there a way to let a scheduler run at a time writen in a db once >> and then rest until the next time occurs? or is a permanent run every few >> seconds checking for certain criteria the better solution? >> >> And just to see if I understood this so far correctly: >> the scheduler function is basically a function I write into the model, >> offering everything a "normal" function offers, exectued at times i >> determine? >> >> Kind regards >> And >> > -- 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 the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.