Search code examples
ruby-on-railsherokubackground-taskclockwork

How to run Clockwork in Heroku


I'm really new to Heroku, but I have a problem. I have created a Clockwork script called "clock.rb" in rails and I use:

bundle exec clockwork clock.rb

to run it in the background on my local server, but How I can run that on Heroku server? (I would like the cheapest solution)

Thanks!!!


Solution

  • To your Procfile use like this

    worker: bundle exec clockwork clock.rb
    

    it will start the server every time after Heroku push/web server restart.

    Or you can run using console from your computer like this but in this case, you need to run every time after web server restarting

    heroku run bundle exec clockwork clock.rb
    

    and from Heroku open console and type

    bundle exec clockwork clock.rb