Would love to be able to have cron like functionality similar to heroku scheduler.
Best,
Jon
Not currently, though we'll keep this issue open as a feature request. For now you can run a process type that watches the clock and does work at the appropriate time.
+1
@titanous If you have a clock process in your Procfile (as it mentions in the docs), that clock process will be happening on N different hosts, right? Which means it'll be up to that process (or whatever background tasks get spawned) to work idempotently, correct?
Just checking my own understanding. 馃槃
@lperiodbose Yes, you are responsible for idempotency. There is no guarantee that there will only be one clock process running, though the scheduler will trend towards the goal of only one process running. I'd suggest using a postgres database for coordination, as it provides strong consistency guarantees.
I'd also love this. Using clockwork is great, but if I'm deploying a Golang app, I don't want Flynn detecting that my app is a Ruby one, purely by the presence of a Gemfile.
+1 to this.
I'm a bit lost with the clock solution :/
I'm using laravel (PHP framework) and i need for each of my 8 websites (more coming) to run this
How can I do it ?
@parweb if you want to use the clockwork Ruby gem, you will need to first configure your app to use both the PHP and Ruby buildpacks by adding and committing a .buildpacks file with the following contents:
https://github.com/heroku/heroku-buildpack-php.git
https://github.com/heroku/heroku-buildpack-ruby.git
You will then need to add and commit the files from this gist:
https://gist.github.com/lmars/f32ad542dea9b34c2c79e63ceef0e15a
An explanation of each file:
clock.rb - this is the definition of your clockwork events (see https://github.com/tomykaira/clockwork#anatomy-of-a-clock-file)Gemfile and Gemfile.lock - these instruct the Ruby buildpack to install the clockwork gemProcfile - this tells Flynn how to start the clock process typePush those changes then scale the clock process type with flynn scale clock=1. You can see the clockwork output with:
$ flynn log -t clock
If it's as simple as running every second, you could also deploy a bash script as the clock process type:
while true; do
php /path/to/artisan schedule:run
sleep 1
done
If your app is Python based and don't like to introduce another tool in stack, you can use APScheduler described here https://devcenter.heroku.com/articles/clock-processes-python
Alternatively, there is Celery Beat as well.
Thanks for all your replies.
I'll try the @lmars solution seems complete for automation.
@titanous Can you explain more how to use the bash script?
Flynn is unmaintained and our infrastructure will shut down on June 1, 2021. See the README for details.
Most helpful comment
@parweb if you want to use the clockwork Ruby gem, you will need to first configure your app to use both the PHP and Ruby buildpacks by adding and committing a
.buildpacksfile with the following contents:You will then need to add and commit the files from this gist:
https://gist.github.com/lmars/f32ad542dea9b34c2c79e63ceef0e15a
An explanation of each file:
clock.rb- this is the definition of your clockwork events (see https://github.com/tomykaira/clockwork#anatomy-of-a-clock-file)GemfileandGemfile.lock- these instruct the Ruby buildpack to install the clockwork gemProcfile- this tells Flynn how to start theclockprocess typePush those changes then scale the clock process type with
flynn scale clock=1. You can see the clockwork output with: