Auto start?
Is there any way to auto start on boot? Also, if you reboot and try to start it manually, it says
Error: The PID directory (/opt/postal/app/tmp/pids) is not empty. Cannot start unless things are clean.
It sounds like rebooting isn't shutting things down cleanly. I will look into this. Can you confirm the operating system you're using?
As for starting automatically, it shouldn't be too tricky to add a systemd script to handle this. I will look into that too.
@adamcooke We see the same thing when a reboot is issued.
Easy enough to just remove those and start on rc.local as a temporary solution.
I will use monit to start it on boot, and also to check that it is working (in case it stop). If you like I can share the monit script
The Procodile supervisor will monitor the individual child processes that it spawns and will restart them if they die unexpectedly. Your Monit script should monitor the supervisor process. Please do share your script though it may be useful to someone 👍
Sure, the thing is that I have to wait until you fix the pids problem on postal stop, because now I had to create a .sh file to take care of it.
The postal.conf file for Monit is just this
check process postal with pidfile /opt/postal/app/tmp/pids/procodile.pid
start program = "/bin/su root -c '/usr/bin/start-postal.sh'"
stop program = "/bin/su root -c '/usr/bin/postal stop'"
if does not exist then start
But instead of "start-postal.sh", it should say only "postal start". But that fails until you remove the pids. So final file is
check process postal with pidfile /opt/postal/app/tmp/pids/procodile.pid
start program = "/bin/su root -c '/usr/bin/postal start'"
stop program = "/bin/su root -c '/usr/bin/postal stop'"
if does not exist then start
Same issue here: Error: The PID directory (/opt/postal/app/tmp/pids) is not empty. Cannot start unless things are clean.
any solutions yet?
This is fixed in Procodile v1.0.16. If you upgrade that, you should find it cleans that directory when it starts. To upgrade, stop postal and then install the latest version.
postal stop
sudo gem install procodile
postal start
I've added a crontab entry to restart postal at boot and apply the iptables configuration and it works nicely.
Hi,
I create webmin start on boot service... (Ubntu 20lts..)
but whitout:
nano /lib/systemd/system/postal.service
content:
[Unit]
Description=Postal Mail Platform
After=mysql.service rabbitmq-server.service
Wants=mysql.service rabbitmq-server.service
[Service]
ExecStart=/usr/bin/postal start
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start postal
systemctl enable postal
Status and stop not working but goal is Start on boot ;)
Not only start on boot add cron user root start evry 1 minute because if network problem in server postal he braced himself and stopped and if not run start evry 1 minute remain postal stoped..:
sudo crontab -u root -e
@reboot postal start >> /postalcron.log
* * * * * postal start >> /postalcron.log
For my this is good solution... IF apper in time better solution plese share here.. Thx.
This might be a long way around but this is how I got postal to start automatically on reboot and/or on crash -
I created the following script -
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
grab current status of postal and store it in a text file
/opt/postal/install/bin/postal status>/root/scripts/pstatus.txt
read the text file with sed and look for the status of postal worker
store that status in the variable $postalworker
postalworker=$(sed -n "s/.*worker *\([^ ]*\)/\1/p" /root/scripts/pstatus.txt)
if statement to read contents of postalworker variable
if its status is running, do nothing
otherwise, start postal
if [ $postalworker == "running" ]; then
echo "postal worker is running";
else
postal start
fi
I made the script writable -
chmod u+x /root/scripts/postal-check.sh
Then I scheduled it to run every minute via cron -
crontab -e
* * * * * /root/scripts/postal-check.sh
May be a complicated way of doing it, but its working. Just posting here seeing as this result comes up top when I google postalserver auto start and maybe someone else has the same issue.
If you're using docker as per version 2, then you should modify the docker-compose.yml file to include restart: unless-stopped for each service or some other setting as per your needs.
You will need to postal stop and postal start to apply the updated file.
Thanks @willpower232 that worked perfectly. My knowledge of docker is very limited and I did not understand how that config file was being used. Now that I edited the file (which is located here on my system - /opt/postal/install/docker-compose.yml) then I restarted and it comes online automatically :-)