Project

General

Profile

Bug #4283

"/etc/init.d/rudder-server-root status" returns no pid for postgres on ubuntu

Added by Dennis Cabooter over 6 years ago. Updated about 5 years ago.

Status:
Released
Priority:
4
Category:
Packaging
Target version:
Severity:
User visibility:
Effort required:
Priority:

Description

Description:

"/etc/init.d/rudder-server-root status" returns no pid for postgres on ubuntu

Output of script:

# /etc/init.d/rudder-server-root status
Apache2 is running (pid 2713).
Jetty running pid=3318
rudder-agent[11680]: [INFO] Using /etc/default/rudder-agent for configuration
rudder-agent[11683]: [INFO] Using /var/rudder/cfengine-community for CFEngine workdir
rudder-agent[11686]: [INFO] All configured CFEngine Community processes are running
postgres[]: Running clusters: 9.1/main 
slapd[11712]: [INFO] Using /etc/default/slapd for configuration
slapd[11718]: [INFO] Process slapd is running
slapd[11732]: [INFO] Detected suffix: cn=rudder-configuration

The problem:

There is no postmaster process running:

# ps axf | grep postmaster | grep -v grep | cut -d" " -f 2
#

The processes that are running:

# ps axf | grep postgres | grep -v grep
 1075 ?        S      0:02 /usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main -c config_file=/etc/postgresql/9.1/main/postgresql.conf
 1080 ?        Ss     0:08  \_ postgres: writer process                                                                                                    
 1081 ?        Ss     0:02  \_ postgres: wal writer process                                                                                                
 1082 ?        Ss     0:01  \_ postgres: autovacuum launcher process                                                                                       
 1083 ?        Ss     0:05  \_ postgres: stats collector process                                                                                           
 1298 ?        Ss    13:21  \_ postgres: rudder rudder 127.0.0.1(51669) idle                                                                               
 3457 ?        Ss     0:23  \_ postgres: rudder rudder 127.0.0.1(51743) idle                                                                               
 3500 ?        Ss     1:08  \_ postgres: rudder rudder 127.0.0.1(51746) idle

Possible solutions:

# ps axf | grep postgres | grep -v grep | head -1 | cut -d " " -f 2
1075

A cleaner one in my humble opinion:

# head -1 /var/lib/postgresql/9.1/main/postmaster.pid
1075

suggested patch:

--- rudder-server-root.old    2013-12-20 15:46:17.000000000 +0100
+++ rudder-server-root    2013-12-20 16:10:33.000000000 +0100
@@ -59,7 +59,7 @@
 /etc/init.d/jetty check | tail -1
 /etc/init.d/rudder-agent status
 # Add PostgreSQL PID to the output
-echo -n "postgres[$(ps axf | grep postmaster | grep -v grep | cut -d" " -f 2)]: " 
+echo -n "postgres[$(head -1 /var/lib/postgresql/9.1/main/postmaster.pid)]: " 
 /etc/init.d/postgresql* status
 /etc/init.d/slapd status
 }

Comments:

!!! The above solution is NOT tested on other systems than Ubuntu 12.04.3 LTS !!!

#1

Updated by Dennis Cabooter over 6 years ago

With the above patch on Ubuntu 12.04.3 LTS, the init script works as expected:

# /etc/init.d/rudder-server-root status
Apache2 is running (pid 2713).
Jetty running pid=3318
rudder-agent[13063]: [INFO] Using /etc/default/rudder-agent for configuration
rudder-agent[13066]: [INFO] Using /var/rudder/cfengine-community for CFEngine workdir
rudder-agent[13069]: [INFO] All configured CFEngine Community processes are running
postgres[1075]: Running clusters: 9.1/main 
slapd[13100]: [INFO] Using /etc/default/slapd for configuration
slapd[13107]: [INFO] Process slapd is running
slapd[13122]: [INFO] Detected suffix: cn=rudder-configuration
#2

Updated by Nicolas CHARLES over 6 years ago

  • Status changed from New to 8
  • Assignee set to Matthieu CERDA
  • Target version set to 2.6.10

Thank you for this patch. However, it works only on Ubuntu, with a recent version on Ubuntu, so we'll need to find a more cross plateform approach
I like the idea of using the pid

On postgres startup script, the pid is obtained via

eval DATADIR=${POSTGRES_DATADIR:-~postgres/data}
PIDFILE=$DATADIR/postmaster.pid

or
pidfile="/var/run/postmaster.${PGPORT}.pid" 

given the version or os

Matthieu, you are the expert for this

#3

Updated by Vincent MEMBRÉ over 6 years ago

  • Target version changed from 2.6.10 to 2.6.11
#4

Updated by Matthieu CERDA over 6 years ago

  • Project changed from Rudder to packages
  • Status changed from 8 to In progress
  • Priority changed from N/A to 4

I'd go for a simpler approach: searching for the postmaster.pid file in /var/lib, and reading from it. It would work on basically any OS :)

Implementing.

#5

Updated by Matthieu CERDA over 6 years ago

  • Target version changed from 2.6.11 to 2.8.3

The "status" argument exists on rudder-server-root only from 2.8 onwards, retargetting.

#6

Updated by Matthieu CERDA over 6 years ago

  • Status changed from In progress to Pending technical review
  • Assignee changed from Matthieu CERDA to Jonathan CLARKE
  • % Done changed from 0 to 100
  • Pull Request set to https://github.com/Normation/rudder-packages/pull/213

PR ready !

#7

Updated by Matthieu CERDA over 6 years ago

  • Status changed from Pending technical review to Pending release

Applied in changeset commit:19bbdd329f32c643cd42631072f3859b8d84cfd0.

#8

Updated by Jonathan CLARKE over 6 years ago

Applied in changeset commit:b025c2132cc42097016174d7f2ca4f0a7e0623d5.

#9

Updated by Vincent MEMBRÉ over 6 years ago

  • Status changed from Pending release to Released

This bug has been fixed in Rudder 2.8.3, which was released today.
Check out:

#10

Updated by Benoît PECCATTE about 5 years ago

  • Project changed from packages to Rudder
  • Category set to Packaging

Also available in: Atom PDF