Scheduling Rake Tasks in Morph Control Panel (Rails)

Subscribe to Scheduling Rake Tasks in Morph Control Panel (Rails) 4 post(s), 4 voice(s)

 
Avatar Harry Administrator 112 post(s)

Rails applications often require scheduled jobs that run in the background. Historically, this has been achieved by running cron jobs. With Morph AppSpace, the process is slightly different. Rather than using cron to execute scheduled jobs, we recommend the use of scheduled Rake tasks.

NOTE: This tip assumes that you already know how to create Rake tasks. For a great tutorial on how to create Rake tasks, see this article from Rails Envy.

Follow these steps to schedule Rake tasks in Morph Control Panel.

  1. Login to Morph Control Panel at http://panel.mor.ph.
  2. On the subscriptions page, click on the “Manage” button in the appropriate subscription widget.
  3. Click on the “Tasks” tab.
  4. In the Tasks page, click on the drop-down box and select the Rake task you want to execute.
  5. In the Arguments field, enter any parameters required by your Rake task during execution.
  6. Lastly, click on one of the three action buttons to either perform the task immediately or execute the task later based on a schedule or event.

The following buttons are available for specifying when your Rake task will execute

  • Run now – Executes the task immediately.
  • Run on date – Allows you to specify the date/time your task will execute and how often.
  • Run on event – Allows you to execute your task when a certain event occurs. For example, immediately after your application has started/restarted.

NOTE: Tasks executed with Run Now have short execution times. See here

 
Avatar Bill Kirtley 9 post(s)

Output from the rake task will be preserved and reported back after the task is finished, but only if it is less than 8k.
A reasonable constraint, but one you might want to be aware of.

 
Avatar robmathews 2 post(s)

Important is a restriction on the execution times of ‘Run On Date’ tasks. Those are limited to “approx 6 hours” according to one post. My experience is 2-3 hours.

Coupled with the undefensible max log file length limit for your rake task, and what you get is tasks that end randomly, leaving no output. sarcarstic comment deleted Comeon, even giving us the last 2k would be nice.

Also, the only events that are current defined are “run on application start”, “run on application stop”.

 
Avatar carolinej Administrator 7 post(s)

Hi robmathews,

Yes, the maximum execution time of ‘Run on Date’ or ‘Run on Event’ is only up to 5 hours of execution time.

‘Before app starts’ and ‘After app has started’ are currently the only defined events in Control Panel.

Please express the events that you want to add. We will forward it to the management for consideration.

Regards,
Caroline