New Discussion

Notifications

You’re not receiving notifications from this thread.

Recurring Domain Expiration Syncing Discussion

4
General

Hi Chris,

I followed your video and at 6:22, I couldn't see the Turbo::Streams and Domain::SyncJob (top 2 jobs). I could see the Domain::SyncAllJob (3rd one).

Inside my /domains listing page, the last checked not being updated.

What could I miss out? I don't see any errors or failed jobs (0). Any tips? Thanks.

@Eric I had the same issue. I updated my code to the below and it seems to be working now. I don't think I can explain why Chris's code worked for him but not for us.

Pay::Subscription.active.includes(customer: :owner).find_each do |subscription|
subscription.customer.owner.domains.find_each do |domain|
domain.sync_later

This looks like it might just be an editing oversight and most likely was also an issue for him.

While the query does return records even without find_each, it only returns the subscriptions themselves. Because there’s no enumerator method chained after (customer: :owner), none of the resulting records are actually yielded to the block. As a result, the following code never gets executed:
subscription.customer.owner.domains.find_each do |domain|
it.sync_later
end

This is actually a solid illustration of an important Ruby concept: any method can be given a block, but that doesn’t mean the method is implemented to use it. In this case, Ruby happily accepts the block, but since the method doesn’t yield, nothing happens—and that’s why the code doesn’t raise an error but fails to create the jobs.

Hey all! I've updated this lesson to include find_each in the SyncAllJob as well as a test to ensure it queues up the correct jobs. 👍

Thanks everyone, but I have some questions.

I have 1 domain listed in /domains, though the sync seems to work (last checked updated like the video).

But in /jobs - finished jobs, I can see

Domain::SyncAllJob - 1
Domain:SyncJob - 3 (gid://domain-monitor/Domain/1, gid://domain-monitor/Domain/2, gid://domain-monitor/Domain/3)
Turbo::Streams::BoradcastStreamJob - 3

Is this normal behavior? Since I have 1 domain listed under this login user, why it runs 3 times in production?

My code as follows
def perform
Pay::Subscription.active.includes(customer: :owner).find_each do |subscription|
subscription.customer.owner.domains.find_each do
it.sync_later
end
end
end

One more thing.

I noticed

kamal deploy
bundle exec kamal deploy

Seems doing the same thing, what's the difference? Both seems to be equally slow to me.

Also I have issues with kamal deploy or redeploy or setup, most of the time will stuck. I have to manually turn off my droplet, turn on it back, then it will be able to run lock release + kamal deploy properly. Is it due to 1 vCPU and 1GB (read online, seems due to Solid queue consuming the OS memory). Looking at the droplet stats, can see memory is always at 80%++. Is this normal for rails 8.1 + solid queue, which I have to get a bigger droplet specs?

Any tips? Thanks.

Join the discussion
Create an account Log in