V5 Self-Host in Docker and cron

Hi All, I’m running v5.0.44-C37 in a docker container.

I just wanted to get a definitive idea - is cron set up and operational in the v5 docker container? Has anyone set up the container to do this or is this feature coming soon?

I’ve attempted a number of different times to get a simple recurring invoice to generate and it doesn’t happen. In the past simply adding a recurring invoice would lock me out of v5 - and now that doesn’t happen now, so I’m just trying to get something to generate.

Some of the basic things I’ve done:

1 - Check the crontab - nothing is setup in any of the directories that I can see. So, I setup a cron to run based on this self-hosted (but non-docker) guide. My crontab looks like this:

1a - I checked that crond was running (albeit as root for now):
image

2 - Watching the cronlog, I setup a recurring invoice to run in the past (as been suggested elsewhere). That suggestion was for V4 - so not telling if that would do anything here. When the next minute arrives, something happens and is logged - even see a reference to recurring invoices:

3 - There is no invoice generated, no email, however. No sign that InvoiceNinja recognized a new invoice needed to be created. Also, the recurring invoice is still sitting there (I had it set only to fire once, so I imagine that should be gone):

4 - I did a php artisan optimize - created a new recurring invoice and started it. Still nothing.
image

5 - I looked at the laravel.log and found no new entries.

So, no invoice and I’m not sure I even expect it to work at this point. I don’t see any documentation referencing corn in a docker container, nor does anyone seem to be specifically talking about this or whether it is even meant to work right now. I’d just love to know where this stands.

6 - Also interesting - with a recurring invoice - when I click “View PDF,” I get an error:
image
The PDF system is otherwise working for me.

7 - And another thing - The one recurring invoice I have set to “Start” is sitting “Pending”. When I use the menu to set it to “Stop,” the recurring invoice continues to say “Pending.” Highly unusual. Take a look here (animated gif).

@cwl

Thanks for the detailed post, it helps a lot!

I think I see a problem in the query we use to get the list of Recurring Invoices to be sent.

I will push a new release today which includes the updated code, if you want to test prior, you’ll want to update the queries in the RecurringInvoicesCron.php file to the following

$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '<=', now())
                                      ->where('status_id', RecurringInvoice::STATUS_ACTIVE)
                                      ->where('remaining_cycles', '!=', '0')
                                      ->with('company')
                                      ->cursor();

That’s amazing, thanks @david - I will test when I get a chance (and with the new version). I appreciate you looking into this.