LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-28-2016, 08:25 AM   #1
incognito3604
LQ Newbie
 
Registered: Apr 2016
Location: Hamburg, Germany
Posts: 12

Rep: Reputation: Disabled
Delay startup for service until network is established


Hello everyone,

can DebIan during booting wait for another server in the Network before starting certain services?

Background:

I have a few servers in our home. A file server running DebIan and some Mini-Servers (Raspberry Pis running Raspbian) fulfilling various tasks from music streaming to TV Recording. The Mini-Server need the file-server to function properly.
If the servers have to restart together (e.g. after a power outage) the Mini-Servers boot a lot quicker than the file server. Correspondingly the Mini-Servers fail to mount the samba shares on the fileserver using the Mini-Servers fstab. This causes hickups for the services on the Mini-Servers.

I have tried some dirty workarounds which work by stopping the services after booting, looping until the server is found and then starting the services again.
This works mostly fine if I don't forget to add any service to this list and they don't cause too much chaos in the few seconds they are alive without the server.

I have looked into messing with the scripts in /etc/rc3.d but this is unreliable.

I would love to have a clean solution. Thank you everyone for your time and energy.
 
Old 09-28-2016, 09:14 AM   #2
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,193
Blog Entries: 7

Rep: Reputation: 336Reputation: 336Reputation: 336Reputation: 336
Which release of Debian?

I remember reading way back that this was one of the use examples of why systemD was sucking up every functionality under the sun. If you're using Jessie or newer, you may want to look into that. It may require you modifying the service file itself. I'm sorry I can't help you more, but if no one else can help, I hope I at least pointed you in the right direction.
 
Old 09-28-2016, 11:03 AM   #3
edmonstone
LQ Newbie
 
Registered: Jul 2016
Location: New England, north of the border
Posts: 11

Rep: Reputation: Disabled
I have done enough of this to be dangerous, but I'll try to get you going on the system and services.

First is that the listings under /etc/rc*.d are indicators of how those services are started on each run level. The actual scripts are found in /etc/init.d.

Second, look into the update-rc.d command. This is the command used to install/uninstall services.

Third, be careful, you can really hose up your system if you do something really wrong. Read through examples on the net and get a good feel for what is going on. You should be fine if you are reasonably careful.

What you want to do is get the networking service to start before your servers. There are headers (LSB headers) in the scripts in /etc/init.d that indicate what if any services should start, already be started, etc. These sections are small and begin with ### BEGIN INIT INFO and end with ### END INIT INFO so they are easy to find. These are used in conjunction with the update-rc.d command to give the system a clue as to how and when things should start.

I don't think there are any rules that say services must start one after the other so you may have to play with which run level your servers start on. Also the LSB numbers you see prepended to the listings under /etc/rcX.d have an impact on the order of things within a run level, but again, there are no guarantees that things will start in 1,2,3 fashion. You may get 1,2 start and 2 isn't fully up, then 3 starts, etc.

I hope this helps.
 
Old 09-28-2016, 03:16 PM   #4
incognito3604
LQ Newbie
 
Registered: Apr 2016
Location: Hamburg, Germany
Posts: 12

Original Poster
Rep: Reputation: Disabled
Hi everyone,

and thank you very much for you contributions.

@goumba: I am running Raspbian 8 Jessie on the server in Mini-Servers. But I am testing these Solutions on a virtualized x64 Version of Debian 8.6

@edmonstone: Thank you very much for the advice with the /etc/init.d folders. I have made a few tests and my impression is that
1) within one runlevel, the services are all started seemingly at once
2) wait and sleep commands in scripts are ignored
3) scripts in /etc/init.d mess up changing runlevels.

It's also not enough to start the services in the right order. The startup process has to wait at a certain point for a condition is fulfilled.
If my fileserver is up I can restart the mini-servers without problems. If I start everything at once my fileserver is to slow in booting, which causes the hickups in the mini-servers.
 
Old 09-28-2016, 05:05 PM   #5
edmonstone
LQ Newbie
 
Registered: Jul 2016
Location: New England, north of the border
Posts: 11

Rep: Reputation: Disabled
Hi incognito3604,

Yes, and the LSBInit headers can't always fix these start dependencies. Even different run levels sometimes don't do it either. I have added to scripts so that they wait for an ip address to be assigned, a proc file to be created, etc. Maybe you can find a solution by modifying the mini-server start scripts?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
server hangs at startup trying to connect to ldap before network service starts saiyen2002 Linux - General 2 07-08-2010 08:07 AM
How to established private network with dial up modem. Bobymc Linux - Networking 2 06-23-2006 11:18 AM
Wireless Network Link Established - No webpage though mrh7184 Linux - Wireless Networking 6 10-04-2005 11:49 PM
why does eth01 fail on startup and delay startup? infantpenguin Linux - Newbie 3 01-28-2005 10:45 AM
Network service startup imurch01 Linux - Networking 6 01-16-2005 10:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration