[Beta] Scheduled tasks not executing after migrating to Environments

I had two tasks seen below (agaarmn_scrape and stateair_scrape) running on scheduled intervals. After I migrated to Environments they stopped running.

I’m going to delete them and re-add them and see if they start working again, just wanted to throw this out there.

If you look below that “Add Task” button, you should see a summary of which environments your scheduled tasks will run in - please can you post a screenshot of the whole tab, then we can help work out what’s going on? Thanks!

Yep noticed that. Perhaps when I migrated it didn’t do what I thought it would. In master I deleted the tasks, readded them, and merged into published.

Then that looks right to me - is the “every 15 mins” task not running?

I reverted my master branch back to a point I believe I merged with the production branch, then closed and reopened the scheduled tasks tab. The tasks were still there. I don’t actually remember when I clicked to migrate to Environments, but I do remember that I was prompted to do so.

I will report back very shortly if the 15 minute task is running.

It doesn’t matter when you migrated, the important thing is that the actual tasks (the top half of that screen) are saved in version control along with the source code that they are running. So the only thing that matters in your current configuration (where Scheduled Tasks are running on the published branch) is what tasks are defined on that branch. In the state shown in your first screenshot above, I would expect the tasks to work.

Well it’s working now. I would guess user error on my part without evidence to the contrary. These tasks were added yesterday (combine_load was added this afternoon), so I believed they would just work, but I may have missed something.

I actually have another app that is using scheduled tasks and I will try to migrate it to Environments and see if the same behavior occurs.

One thing I note is that if I’m on a different branch the scheduled tasks don’t show that they have ever run. Makes sense except that app logs and background tasks status seem to be universal. Not sure how they should be either way but that’s an observation.

Thanks for the update. We’re obviously keeping a close eye on feedback like this as we try to make the various interfaces more accessible.

1 Like

I had the same problem.

Yesterday I enabled the environments for an app and the nightly background task didn’t run.

Yesterday I did check the scheduled tasks, I noticed that both the environments were set to run, so I disabled one of them.

Today I checked and the task didn’t run.

I will redefine it and make sure it works, but I wanted you to know that something went wrong with the automatic switch.

I played a little with removing and redefining the scheduled tasks configuration, then I restarted working on my dev branch.

Later, when I was done and I merged dev to master, I got a merge conflict with the scheduled task configuration.

And now I am confused:

  • When I look at the Scheduled Tasks page I can decide which environment will run the scheduled task, so I think that that page is not affected by what the current branch is
  • When I commit I realize that the scheduled task settings were indeed stored inside the branch that was active while configuring them

I think that specifying which environment will run the scheduled tasks should be an app setting and should not be stored inside an environment.

If my thinking is wrong, then can you please clarify what is the expected behavior?

Imagine that you have 2 environments, each “owned” by a different customer. One wants a Scheduled Task to run every weekend. The other wants the same Scheduled Task to run 3x a day. Each, using their own database.

If the setting was on a per-App basis, not a per-Environment basis, you’d have to play some games to give each Customer their desired behavior.

I don’t understand.

The red settings in this snapshot are stored in the repository, the blue settings seems to be stored in the global app settings:

Why should I need to edit an environment to decide when and whether a scheduled task runs, but I can change that the whether without editing that environment?

You should either set the scheduling inside the app repository or as an app global setting. The current behavior, half in the repository and half outside, seems to be increasing the complexity without giving advantages.

Or am I missing something?

I agree. Apps have elements that span multiple conceptual areas. Which area does that element belong in? Different folks will have different ideas, depending on what uses they have in mind.

Sometimes, it’s best to extract such cross-cutting ideas into a category of their own. In this case, Scheduled Tasks, as a listing unto itself, where you get to set all the parameters of each Scheduled item: whether, when, which Environment, which Task (function), etc. (This might also be a good place to add a note about the item: why it exists, what purpose it serves, what else it depends on, …)

This is now about how the UI is organized, so we’re slipping off the original topic. I suggest that this subtopic be moved to its own Q&A topic.

1 Like

I like the note!

I created a Feature Request.