PostgreSQL 16 database will not run as service, must have a CMD open for it to work

31 views Asked by At

I need some serious help here. Here is the laydown, I have a postgres database set up. For some reason the server will not stay running as a service when attempting to start it in the services app (windows)

When I attempt to start as Local System I receive the "service on local computer started and then stopped. Some services stop automatically if they are not in use by other services etc."

I used my terminal to check the status always using

pg_ctl status -D "C:\Program Files\PostgreSQL\16\data"

This tells me if the server is running, currently it is. However, if I close the command terminal the server stops abruptly and I get this in the log.

2024-03-26 15:13:32.938 PDT [5348] LOG: database system was interrupted; last known up at 2024-03-26 15:06:17 PDT 2024-03-26 15:13:33.313 PDT [5348] LOG: database system was not properly shut down; automatic recovery in progress

So then I go through having to open a new terminal and doing the following

pg_ctl start -D "C:\Program Files\PostgreSQL\16\data" 

to Start the server again, which I have to attempt a handful of times.

then use

pg_ctl status -D "C:\Program Files\PostgreSQL\16\data" 

to Monitor if the server is on, and then I have to leave that terminal open and alone in order for me to access the data via pgAdmin.

Any help is appreciated, there is currently a postmaster.pid file in there that was generated because I tried to start the service and made the terminal crash. In other words, they are not working well together. Any ideas on a fix?

I have tried the following: Ensuring there is no postmaster.pid file in the \16\data path. I shutdown the server using the ctrl_stop command I then try and boot as a service and receive the "service on local computer started and then stopped. Some services stop automatically if they are not in use by other services etc." Error message.

0

There are 0 answers