alex spencer
alex spencer

Reputation: 177

How to prevent procmail from crashing the platform and make it run one process at a time?

I have the problem that I capture emails and they arrive in masses, the issue is that every time they arrive in masses the platform crashes, the question is how to make it go running the process 1 at a time, is it possible? because currently I filled the entire procmail server where there were multiple processes at once, plus we add the executives who were working and the server died and we had to reboot and delete data from the procmail to get it working again.

Because once we capture the data it is working and making subprocesses.

This is the code:

SHELL = /bin/sh
LOGFILE     = /var/log/procmail.log
LOGABSTRACT = "all"
VERBOSE     = "on"

:0c
| php /srv/platform/laravel/artisan platform:catchemail >> /var/log/procmail_catchemail.log 2>&1

:0:
/var/log/plaform_catchemail

Upvotes: 0

Views: 42

Answers (1)

tripleee
tripleee

Reputation: 189297

If by "platform" you mean the PHP script, you can serialize access to it by using a lock file.

:0c:.catchemail.lock
| php /srv/platform/laravel/artisan platform:catchemail >> /var/log/procmail_catchemail.log 2>&1

This means, if the file .catchemail.lock does not exist in your $MAILDIR, go ahead and create it, and hold it for the duration of this recipe.

If it does exist, sleep and try again.

There is a failure scenario if the lock is held for too long; Procmail's default behavior in this case is to bounce the message (i.e. cause the delivering MTA to regard it as undeliverable, and return an error message to the sender). You probably want to avoid that, ideally by telling the MTA to attempt delivery again at a later time. (The precise mechanism will depend on your MTA; but basically, by setting a suitable exit code.) But what's feasible and scalable ultimately depends on how many messages you receive vs how many you can process under this constraint.

Upvotes: 1

Related Questions