2

I have the following script in my rc.local:

This runs the services on ports 8080, 8081, 8082, 8083. They are actually node servers that NEED mongod to startup.

So, I edited /lib/systemd/system/rc-local.service and added:

After=network.target syslog.target mongod.service

But no: the scripts still fail because, at running time, they find that the database server is down.

What could I be doing wrong? How would I debug this?

UPDATE: Now that I added After=, the error is not the mongoDb connection (I was looking at old logs), but rather the fact that rc-local doesn't seem to be starting at all. Running manually systemctl restart rc-local.service works though...

UPDATE 2: By taking syslog.target out, and so having:

After=network.target mongod.service

has the strange side effect that HALF of the servers (2 out of 4) start fine, and the other HALF fail to connect to the database. This makes me think that systemd runs mongodb, but it's not yet ready to take connections when rc-local is run

5
  • You really should write a proper systemd unit to start your node servers, rather than (ab)using rc.local. Commented Feb 26, 2017 at 10:34
  • If I have this problem with rc.local's systemd unit, I will have the exact same issue with any "proper" systemd issue I will ever write Commented Feb 28, 2017 at 7:12
  • You can believe whatever you want to believe. Commented Feb 28, 2017 at 18:19
  • Please explain why another systemd unit wouldn't suffer from the problem rc.local suffers -- thanks! Commented Mar 3, 2017 at 4:19
  • Well you can't can you? Commented Apr 10, 2017 at 7:01

1 Answer 1

-2

As a workaround, why don't you set mongodb not to start using systemctl and set it to start in rclocal before the items you need?

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.