<div dir="ltr"><div><span style="color:rgb(0,0,255)"><font size="4">[Unit]<br>Description=run pgpool<br><br>[Service]<br>After=network.service<br>Type=simple<br>ExecStart=/bin/bash /root/pgpool.sh ## <-change run_XXX.sh<br>Restart=on-failure<br>RestartSec=3 <br>## systemd bears daemon duty<br><br>[Install]<br>WantedBy=multi-user.target</font></span><br><br></div><div> 
<font size="4">/root/pgpool.sh<br><span style="color:rgb(0,0,255)">/usr/bin/pgpool</span></font></div><div><br></div><br><font size="4">And here is the running result (automatically killed by systemd):</font><br><br><span style="color:rgb(0,0,255)"><font size="4">Jul 03 17:36:48 yzx1 systemd[1]: Started run pgpool.<br>Jul 03 17:36:48 yzx1 systemd[1]: auto_pgpool.service: Deactivated successfully.<br>Jul 03 17:36:51 yzx1 sshd[4558]: Invalid user shinken from 180.168.95.234 port 57152<br>Jul 03 17:36:51 yzx1 sshd[4558]: Received disconnect from 180.168.95.234 port 57152:11: Bye Bye [pr><br>Jul 03 17:36:51 yzx1 sshd[4558]: Disconnected from invalid user shinken 180.168.95.234 port 57152 [><br>Jul 03 17:37:28 yzx1 sshd[4561]: Invalid user admin from 43.154.95.120 port 60548<br>Jul 03 17:37:28 yzx1 sshd[4561]: Received disconnect from 43.154.95.120 port 60548:11: Bye Bye [pre><br>Jul 03 17:37:28 yzx1 sshd[4561]: Disconnected from invalid user admin 43.154.95.120 port 60548 [pre></font></span><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 3, 2023 at 4:35 PM Bo Peng <<a href="mailto:pengbo@sraoss.co.jp">pengbo@sraoss.co.jp</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Fri, 30 Jun 2023 15:02:56 +0800<br>
Zhaoxun Yan <<a href="mailto:yan.zhaoxun@gmail.com" target="_blank">yan.zhaoxun@gmail.com</a>> wrote:<br>
<br>
> Hi guys!<br>
> <br>
> I want systemd to monitor pgpool and restart another once it found it is<br>
> dead. So here is this simple service named as auto_pgpool.service<br>
> <br>
> [Unit]<br>
> Description=run pgpool after auto_pgha service ## <-change run_XXX.sh<br>
> <br>
> [Service]<br>
> Type=simple<br>
> ExecStart=/usr/bin/pgpool ## <-change run_XXX.sh<br>
> Restart=on-failure<br>
> RestartSec=3<br>
> ## systemd bears daemon duty<br>
> <br>
> [Install]<br>
> WantedBy=multi-user.target<br>
> <br>
> But it always failed and caused systemd to restart it again and again - *is<br>
> it a false positive? and how can I avoid it?*<br>
> <br>
> Jun 30 14:48:13 yzx1 systemd[1]: Started run pgpool after auto_pgha service<br>
> ## <-change run_XXX.sh.<br>
> ░░ Subject: A start job for unit auto_pgpool.service has finished<br>
> successfully<br>
> ░░ Defined-By: systemd<br>
> ░░ Support: <a href="https://access.redhat.com/support" rel="noreferrer" target="_blank">https://access.redhat.com/support</a><br>
> ░░<br>
> ░░ A start job for unit auto_pgpool.service has finished successfully.<br>
> ░░<br>
> ░░ The job identifier is 10863.<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]: pgpool-II version 4.4.3 (nurikoboshi),<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   A generic connection<br>
> pool/replication/load balance server for PostgreSQL<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]: Usage:<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   pgpool [ -c] [ -f CONFIG_FILE ] [ -F<br>
> PCP_CONFIG_FILE ] [ -a HBA_CONFIG_FILE ]<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:          [ -n ] [ -D ] [ -d ]<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   pgpool [ -f CONFIG_FILE ] [ -F<br>
> PCP_CONFIG_FILE ] [ -a HBA_CONFIG_FILE ]<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:          [ -m SHUTDOWN-MODE ] stop<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   pgpool [ -f CONFIG_FILE ] [ -F<br>
> PCP_CONFIG_FILE ] [ -a HBA_CONFIG_FILE ] reload<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]: Common options:<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -a, --hba-file=HBA_CONFIG_FILE<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       Set the path to<br>
> the pool_hba.conf configuration file<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       (default:<br>
> /usr/etc/pool_hba.conf)<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -f, --config-file=CONFIG_FILE<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       Set the path to<br>
> the pgpool.conf configuration file<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       (default:<br>
> /usr/etc/pgpool.conf)<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -k, --key-file=KEY_FILE<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       Set the path to<br>
> the pgpool key file<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       (default:<br>
> /root/.pgpoolkey)<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       can be over ridden<br>
> by PGPOOLKEYFILE environment variable<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -F, --pcp-file=PCP_CONFIG_FILE<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       Set the path to<br>
> the pcp.conf configuration file<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       (default:<br>
> /usr/etc/pcp.conf)<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -h, --help          Print this help<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]: Start options:<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -C, --clear-oidmaps Clear query cache<br>
> oidmaps when memqcache_method is memcached<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       (If shmem,<br>
> discards whenever pgpool starts.)<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -n, --dont-detach   Don't run in<br>
> daemon mode, does not detach control tty<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -x, --debug-assertions   Turns on<br>
> various assertion checks, This is a debugging aid<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -D, --discard-status Discard<br>
> pgpool_status file and do not restore previous status<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -d, --debug         Debug mode<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]: Stop options:<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   -m, --mode=SHUTDOWN-MODE<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:                       Can be "smart",<br>
> "fast", or "immediate"<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]: Shutdown modes are:<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   smart       quit after all clients<br>
> have disconnected<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   fast        quit directly, with proper<br>
> shutdown<br>
> Jun 30 14:48:13 yzx1 pgpool[5575]:   immediate   the same mode as fast<br>
> *Jun 30 14:48:13 yzx1 systemd[1]: auto_pgpool.service: Main process exited,<br>
> code=exited, status=1/FAILURE*<br>
<br>
It seems "pgpool" command failed.<br>
Could you run run_XXX.sh script to start pgpool?<br>
<br>
> ░░ Subject: Unit process exited<br>
> ░░ Defined-By: systemd<br>
> ░░ Support: <a href="https://access.redhat.com/support" rel="noreferrer" target="_blank">https://access.redhat.com/support</a><br>
> ░░<br>
> ░░ An ExecStart= process belonging to unit auto_pgpool.service has exited.<br>
> ░░<br>
> ░░ The process' exit code is 'exited' and its exit status is 1.<br>
> Jun 30 14:48:13 yzx1 systemd[1]: auto_pgpool.service: Failed with result<br>
> 'exit-code'.<br>
> ░░ Subject: Unit failed<br>
> ░░ Defined-By: systemd<br>
> ░░ Support: <a href="https://access.redhat.com/support" rel="noreferrer" target="_blank">https://access.redhat.com/support</a><br>
> ░░<br>
> ░░ The unit auto_pgpool.service has entered the 'failed' state with result<br>
> 'exit-code'.<br>
> Jun 30 14:48:16 yzx1 systemd[1]: auto_pgpool.service: Scheduled restart<br>
> job, restart counter is at 167.<br>
<br>
<br>
-- <br>
Bo Peng <<a href="mailto:pengbo@sraoss.co.jp" target="_blank">pengbo@sraoss.co.jp</a>><br>
SRA OSS LLC<br>
TEL: 03-5979-2701 FAX: 03-5979-2702<br>
URL: <a href="https://www.sraoss.co.jp/" rel="noreferrer" target="_blank">https://www.sraoss.co.jp/</a><br>
</blockquote></div>