Running a robust ERP system like iDempiere requires more than just a successful installation; it requires a mechanism to ensure the service stays online 24/7. In this guide, we will walk through the process of configuring a systemd service (often referred to as a “watchdog” setup) to manage your iDempiere instance automatically.

Why Use Systemd for iDempiere?

By default, running a script manually in the terminal is risky. If the terminal closes or the application crashes, the ERP goes down. By using systemd, you gain:

  • Auto-Start: iDempiere starts automatically when the server boots.
  • Auto-Restart: If the service crashes, Linux will automatically attempt to restart it.
  • Dependency Management: Ensures iDempiere only starts after the database (PostgreSQL) is ready.

Prerequisites

  • Ubuntu Server installed and updated.
  • iDempiere installed in /home/idempiere/idempiere/.
  • A dedicated system user named idempiere.

Step 1: Create the Service File

First, you need to create a configuration file that tells Ubuntu how to handle iDempiere. Open your terminal and create the following file:

Bash

sudo nano /etc/systemd/system/idempiere.service

Step 2: The Configuration Code

Copy and paste the following configuration into the file. This setup ensures that the system waits for PostgreSQL and restarts iDempiere every 10 seconds if it fails.

[Unit]
Description=iDempiere ERP Service
After=network.target

[Service]
Type=simple
User=idempiere
WorkingDirectory=/home/idempiere/idempiere/
ExecStart=/bin/bash /home/idempiere/idempiere/idempiere-server.sh
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Breakdown of Key Parameters:

  • After=postgresql.service: This is critical. It prevents iDempiere from trying to connect to a database that hasn’t finished booting yet.
  • User=idempiere: For security, we run the application under a non-root user.
  • ExecStart: Points to the official startup script provided by iDempiere.
  • Restart=always: This acts as your “watchdog.” If the process dies for any reason, systemd will trigger a restart.
  • RestartSec=10: This adds a 10-second delay between restart attempts to prevent “rapid-fire” crashing loops that could stress the CPU.

Step 3: Enable and Start the Service

Once the file is saved, you must notify the system of the new configuration and enable it to run at boot.

  1. Reload the systemd daemon: sudo systemctl daemon-reload
  2. Enable the service to start at boot: sudo systemctl enable idempiere.service
  3. Start the service immediately: sudo systemctl start idempiere.service

Step 4: Verify the Status

To confirm that your iDempiere “watchdog” is working correctly, check the service status:

Bash

sudo systemctl status idempiere.service

You should see an “active (running)” status. If you ever need to view the real-time logs to troubleshoot, use:

Bash

journalctl -u idempiere.service -f

Conclusion

With these few steps, you have transformed your iDempiere installation into a resilient, production-ready service. This setup minimizes downtime and ensures that your ERP environment is always available for your users.

By Ray Lee (System Analyst)

iDempeire ERP Contributor, 經濟部中小企業處財務管理顧問 李寶瑞

Leave a Reply

Your email address will not be published. Required fields are marked *