Restart services on multiple servers/nodes in interval with one liner


Recommended Posts

Hey Guys,

 

An interesting question came to me while I was talking to some of my friends. One of them has to restart a service via chef on a number of servers but he needs each server to start the service after a interval. The reason for this because the service he is starting will cause a rebalance and he wants to slowly restart the services on all hosts while the other ones catch the load and redistribute etc. He said it had to be a one liner because he wanted to push it via chef and chef pushes to all of the servers at once. In theory, if the push makes it to all of the servers at the same time, he wants each server to wait and then restart. The wait would be longer enough so the previous server's service has restarted and is back up.


I was thinking something along the line of sleep, time, etc all in a one liner but then thinking about it, all of the servers would respond the same. I am not looking for the answer but i'm looking to learn from fellow linux users / sysadmins on how one would go on "solving" this problem. 
 

I have downloaded chef and plan on installing it at home on all my servers and playing with it this weekend. But in general, I'm very curious as to how this would work in a datacenter with hundreds of servers where a service needs to be restarted after a specific interval so the previous servers can catch the load and it goes unnoticed.


Any help or feedback is appreciated.

 

Thanks

Sikh

  • Like 1
Link to comment
Share on other sites

Just now, farmeunit said:

Not familiar with chef, but why not just run the scripts remotely with SSH?  I'm sure there are several ways to do it. 

I dont disagree but chef is a automation tool that will push a command to all of your nodes at once. So you can do anything with say 50-10k machines with just one push. So this is a "one push for all machines" and not individual machines question. 

  • Like 1
Link to comment
Share on other sites

Wow. I can see this being useful for anyone, at any scale. Need to push update commands to the computers on your home network? Poof, it is done, continue upon the path of righteousness.

 

Another useful one for the tool bin. :yes: Thanks, @Sikh! I'll have to check this one out. :) 

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.