I'm using CentOS 7. I have a nodeJS server I want to run as a service, but I would prefer the service started after my PostGres 9.6 server had booted. I tried specifying after in my service description (/usr/lib/systemd/system/nodesrv.service) ...
[Unit] Description=NodeService nodejs server [Service] User=rails Group=rails ExecStart=/home/rails/myrailssite_production/NodeService/start.sh ExecStop=/home/rails/myrailssite_production/NodeService/stop.sh Type=forking RemainAfterExit=yes After=postgresql-9.6.service [Install] WantedBy=multi-user.target
However, I think PostGres still needs a few seconds to boot up because I see this in the output for the above service
[rails@server ~]$ sudo journalctl -u nodesrv [sudo] password for rails: -- Logs begin at Mon 2018-06-11 11:08:17 EDT, end at Mon 2018-06-11 11:09:40 EDT. -- Jun 11 11:08:17 server systemd: Starting NodeService nodejs server... Jun 11 11:08:17 server start.sh: psql: could not connect to server: No such file or directory Jun 11 11:08:17 server start.sh: Is the server running locally and accepting Jun 11 11:08:17 server start.sh: connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Is there a way to specify not to run the script until PostGres is up and running? I realize there might be circumstances in which PostGres fails to boot at all in which case I'm fine with never running the service.