[SERVER-13595] Red Hat init.d script error: YAML config file parsing Created: 15/Apr/14  Updated: 11/Jul/16  Resolved: 13/May/14

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: 2.6.0
Fix Version/s: 2.6.6, 2.7.1

Type: Bug Priority: Major - P3
Reporter: Jon Rangel (Inactive) Assignee: Ernie Hershey
Resolution: Done Votes: 0
Labels: cap-ticket-needed
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
is duplicated by SERVER-15796 "/etc/init/mongod stop" not working Closed
is duplicated by SERVER-14095 CentOS 6 init script unable to stop m... Closed
Related
related to SERVER-14247 init script now set env var PIDFILEPA... Closed
related to SERVER-16720 Init script in Red Hat fails if using... Closed
related to SERVER-16731 Remove unused DBPATH init script vari... Closed
is related to SERVER-18060 init.d script for cents does not supp... Closed
Tested
Operating System: Linux
Backport Completed:
Sprint: Build Team 2.7.0, BUILD 2.7.1, BUILD 2.8.0-rc2
Participants:

 Description   

In 2.6, MongoDB now supports YAML configuration files.

The /etc/rc.d/init.d/mongod script in the mongodb-org RPM package doesn't work because of the following line that parses the pidfile path from the config file:

PIDFILE=`awk -F= '/^pidfilepath[[:blank:]]*=[[:blank:]]*/{print $2}' "$CONFIGFILE"`

The above line doesn't correctly parse YAML configuration files, so the init.d script is unable to retrieve the pidfile needed to stop the mongod service.

The regex should be modified to cover both old and new style configuration files. The following works for YAML files:

PIDFILE=`awk -F: '/^[[:blank:]]*pidFilePath[[:blank:]]*:[[:blank:]]*/{print $2}' "$CONFIGFILE" | tr -d ' '`



 Comments   
Comment by Githook User [ 18/Nov/14 ]

Author:

{u'username': u'ehershey', u'name': u'Ernie Hershey', u'email': u'ernie.hershey@10gen.com'}

Message: SERVER-13595 Adjust rpm init script awk line to read new yaml config file format
Branch: v2.6
https://github.com/mongodb/mongo/commit/19bcb1fadddfc72b21329809c9964ac279c5e194

Comment by Githook User [ 13/May/14 ]

Author:

{u'username': u'ehershey', u'name': u'Ernie Hershey', u'email': u'ernie.hershey@10gen.com'}

Message: SERVER-13595 Adjust rpm init script awk line to read new yaml config file format
Branch: master
https://github.com/mongodb/mongo/commit/5368b375128302c1bb32ec7c5e6d5b7e6c5cd38b

Comment by Ernie Hershey [ 16/Apr/14 ]

I think this slightly adjusted line will work for both cases. It depends on an advanced enough version of awk to understand IGNORECASE.

PIDFILE=`awk -F'[:=]' -v IGNORECASE=1 '/^[[:blank:]]*pidfilepath[[:blank:]]*[:=][[:blank:]]*/{print $2}' "$CONFIGFILE" | tr -d ' '`

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