[SERVER-16720] Init script in Red Hat fails if using YAML inline syntax Created: 05/Jan/15  Updated: 15/Apr/15  Resolved: 05/Jan/15

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: 2.6.6
Fix Version/s: 2.8.0-rc5

Type: Bug Priority: Minor - P4
Reporter: andrea maria piana Assignee: Ernie Hershey
Resolution: Done Votes: 0
Labels: pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Centos 7


Issue Links:
Related
related to SERVER-16721 Allow init script PIDFILEPATH to be c... Closed
related to SERVER-16731 Remove unused DBPATH init script vari... Closed
is related to SERVER-13595 Red Hat init.d script error: YAML con... Closed
is related to SERVER-18060 init.d script for cents does not supp... Closed
is related to SERVER-17337 RPM Init script breaks with quotes in... Closed
Backwards Compatibility: Fully Compatible
Operating System: Linux
Steps To Reproduce:

1) Install Mongodb 2.6 on centos
2) add the line in /etc/mongod.conf
processManagement.pidFilePath: /var/run/mongod/mongod.pid
3) Make sure /var/run/mongod does not exist ( it's removed at each shutdown )
4) /etc/init.d/mongod start should fail with error: "directory /var/run/mongod does not exist"

Participants:

 Description   

When using YAML inline syntax, for example:
processManagement.pidFilePath: /var/run/mongod/mongod.pid
instead of:
processManagement:
pidFilePath: /var/run/mongod/mongod.pid
the init script is not able to pick up the correct DBPATH and PIDFILEPATH and fails if directory is not present.



 Comments   
Comment by Ernie Hershey [ 20/Feb/15 ]

Good catch - I created SERVER-17337 to track that problem.

Comment by Kevin Pankonen [ 20/Feb/15 ]

The init script is still broken if you're quoting the paths (which is shown in the configuration documentation http://docs.mongodb.org/manual/reference/configuration-options/)

Here's the config
processManagement:
pidfilepath: "/var/run/mongodb/mongod.pid"

Here's the useful part of script:
++ tr -d '[:blank:]'
++ awk '-F[:=]' -v IGNORECASE=1 '/^[[:blank:]](processManagement\.)?pidfilepath[[:blank:]][:=][[:blank:]]*/

{print $2}

' /etc/mongod.conf
+ PIDFILEPATH='"/var/run/mongodb/mongod.pid"'
+ mongod=/usr/bin/mongod
+ MONGO_USER=mongod
+ MONGO_GROUP=mongod
+ '[' -f /etc/sysconfig/mongod ']'
+ . /etc/sysconfig/mongod
++ dirname '"/var/run/mongodb/mongod.pid"'
+ PIDDIR='"/var/run/mongodb'

PIDFILEPATH gets set to "/var/run/mongod.pid" (includes the quotes), dirname includes the first "

Comment by Githook User [ 05/Jan/15 ]

Author:

{u'username': u'cammellos', u'name': u'Andrea Maria Piana', u'email': u'a.piana@77agency.com'}

Message: SERVER-16720 updated awk regexp to support inline pidFilePath and dbPath syntax

Closes #899

Signed-off-by: Benety Goh <benety@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/e82c06607baf14a00751af681b808c3172bdeff0

Comment by andrea maria piana [ 05/Jan/15 ]

I have updated the init file to address this scenario and opened a pull request https://github.com/mongodb/mongo/pull/899

Generated at Thu Feb 08 03:42:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.