Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit the number of instances UpStart can simultaneously start or respawn

I have a UpStart service job that has many (~100) instance that need to be started. Each of them is a resource-heavy process that does a lot of disk reading/writing during startup. When all of them start or respawn at the same time, they cause trouble due to excessive disk read/write requests.

I need a way to limit the number of instances that UpStart tries to start or respawn simultaneously. For example, is there a way to let UpStart hold off launching another instance until, say 30 seconds, after the startup or respawning of another instance has begun?

like image 858
Shanqing Cai Avatar asked May 13 '15 20:05

Shanqing Cai


2 Answers

You can start them in sequence by using

start on started otherUpstartService
like image 118
Alex Avatar answered Sep 20 '22 08:09

Alex


You can use pre-start or post-stop to pause after each job. E.g post-stop exec sleep 5

like image 39
Kremnev Sergey Avatar answered Sep 20 '22 08:09

Kremnev Sergey