0

I try to set up an Ubuntu server so it start specific services (daemon) only when machine uses specific IP.

The idea is that I have a server to run some service on (and service is RAM-intensive), the server has its static IP. I would like to have copy of that server with different IP (but with all the same software installed on it), and I'd like to have this specific service to start at machine startup only if its IP is the specific one.

This way I can use backup machine for some other purposes (so the hardware will be used anyway), but in the case primary machine fail to run I can manually change the IP of backup machine to IP of the primary, reboot it and have specific service run under same IP.

The Ubuntu is 16.04 LTS.

Please advice!

Alexander
  • 774
  • 2
  • 11
  • 20
  • 1
    If your workflow involves having to manually change the IP and reboot the server, I would just add 'turn on the service' to my workflow. This seems like a rather random thing to automate out of this plan. –  Aug 17 '17 at 16:47
  • @yoonix Yes this kind of solution but the workflow may involve several steps that are under scripting control so it would be logical to tie the script execution to the fact what IP is on the server. – Alexander Aug 17 '17 at 17:05
  • It wouldn't be logical. 'Something' needs to change the IP, you should tie it to that. Not the results of that. –  Aug 17 '17 at 17:18
  • 1
    Is this a daemon or a script? If the former: Bind the daemon to the IP, by default, if the IP is not available, the daemon should fail to start. If it's the later, check for the IP in the script, and exit early, if the IP isn't available. – gxx Aug 17 '17 at 19:27
  • @gf_ It is nice idea to bind daemon to IP (and I will try to), but the problem is, I do need to to have it bind to server IP and to localhost, so I have to check if it is possible to bind to two interfaces/IPs at the same time. But good approach, really. In fact the only other way I can imagine is to disable/enable daemon startup right as the network init is done (that is, on if-up event, maybe), but I'm not sure if it is good idea. – Alexander Aug 17 '17 at 20:49
  • Which daemon is this? Something standard, or self-written? It should be possible, if the former. If it isn't, create a wrapper script which checks first if the IP is available (exit if it isn't), and after this, start the daemon. – gxx Aug 17 '17 at 21:21

0 Answers0