digitalmars.D.learn - Running task once a day in vibe.d
- Nick (5/5) Feb 16 2016 Hey folks
- Chris Wright (11/17) Feb 16 2016 http://vibed.org/api/vibe.core.core/runTask
- sigod (3/8) Feb 16 2016 You can use `Timer`. See `setTimer`/`createTimer` in
- Nick (1/1) Feb 17 2016 Thank you very much, this was exactly what I was looking for!
- Zardoz (3/8) Feb 17 2016 Why you not use cron to launch your program at desire time every
- Chris Wright (19/28) Feb 17 2016 Instead of just extracting an archive in a particular directory, you now...
Hey folks I'm making a vibe.d application. Once a day it needs to download some data. How do i get the program to perform this task once a day? Regards, Nick
Feb 16 2016
On Tue, 16 Feb 2016 18:30:43 +0000, Nick wrote:Hey folks I'm making a vibe.d application. Once a day it needs to download some data. How do i get the program to perform this task once a day? Regards, Nickhttp://vibed.org/api/vibe.core.core/runTask http://vibed.org/api/vibe.core.core/sleep Run a task in your application setup. Have it sleep until the appointed time, then execute the job in accordance with the prophecy. I'd have it run your daily job in a separate fiber for error isolation. If you want to run it at particular times of day, run if the application crashed before the appointed time, do the right thing with daylight savings, execute once across multiple processes, etc, I don't think that currently exists for vibe.d. It's a decent chunk of work to make all that happen properly.
Feb 16 2016
On Tuesday, 16 February 2016 at 18:30:43 UTC, Nick wrote:Hey folks I'm making a vibe.d application. Once a day it needs to download some data. How do i get the program to perform this task once a day? Regards, NickYou can use `Timer`. See `setTimer`/`createTimer` in http://vibed.org/api/vibe.core.core/
Feb 16 2016
Thank you very much, this was exactly what I was looking for!
Feb 17 2016
On Tuesday, 16 February 2016 at 18:30:43 UTC, Nick wrote:Hey folks I'm making a vibe.d application. Once a day it needs to download some data. How do i get the program to perform this task once a day? Regards, NickWhy you not use cron to launch your program at desire time every day ?
Feb 17 2016
On Wed, 17 Feb 2016 18:55:42 +0000, Zardoz wrote:On Tuesday, 16 February 2016 at 18:30:43 UTC, Nick wrote:Instead of just extracting an archive in a particular directory, you now have to edit your crontab. It's another thing that can go wrong outside your code. On the other hand, cron is pretty reliable. More reliable than what I'd hack up in a day. On the *other* other hand, cron is entirely generic. I don't know what it will do if, for instance, my server is power cycling when the cron job should run. I don't know what will happen if your server is off for three whole days and you turn it back on again. What does your application require? Does it line up with what cron offers? But if you write it yourself, you know what your task scheduler will do. You know what logs you need to watch. Also, speaking of logs: if you have a logwatch daemon that's looking for problems from your logfile, putting everything in the same process can simplify that a bit. Or if you have a webservice that has a status page, it might be easier to do if the daily task is executed in-process. As a compromise, you could have a simple 'curl http://localhost/dailytask/ execute' as a cronjob.Hey folks I'm making a vibe.d application. Once a day it needs to download some data. How do i get the program to perform this task once a day? Regards, NickWhy you not use cron to launch your program at desire time every day ?
Feb 17 2016