So I have received no recommendation to this.
There was no problem with the systemd service,
but (to be more portable,...) I have moved now to the scheduler.
If somebody is interested, here is my code.
I can/need initialize the scheduler with one (admins) access to url
myapp/sysadmin/start_idx.
@auth.requires_membership('admin')
def start_idx():
if DEBUG_SCHEDULER:
idx()
return 'Indexing finished.'
else:
if db((db.scheduler_task.application_name == 'codex2020/sysadmin') &
(db.scheduler_task.task_name == 'idx')).select().first():
return 'Task idx already queued. Remove it from scheduler_task
table if you want re-create it.'
else:
scheduler.queue_task(
idx,
pargs=[],
pvars={},
start_time=datetime.datetime.now(),
stop_time=None,
timeout=2147483647,
prevent_drift=False,
period=20,
immediate=False,
repeats=0
)
return 'Task idx was added.'
On Thursday, 27 October 2016 12:36:06 UTC+2, Mirek Zvolský wrote:
>
> I need run a script which for marked records in one table creates
> "indexing" or "helpers" records in another table.
> This script should:
> - switch this activity and sleep(10) /should sleep after it will not find
> any marked record/
> - run always
> - run in 1 instance only /to avoid indexing of same records from 2
> instances/
>
> I decide to solve it as systemd service.
> My QUESTION IS: Is this good decision, or should I use something web2py
> specific (scheduler?) ?
>
> -----------------
> If somebody is interested in the "systemd service" solution, I made in
> based on this article:
>
> http://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/
>
> ...and I have added into the [service] section: Restart=on-failure
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.