I have an upstart job X that control some web processes. During shutdown, I want to make sure that X is stopped after /etc/init.d/nginx, so that there won't be any 502 returned to the HAProxy instance fronting this server. HAProxy does health check every 2 seconds, and if X is stopped first, there can a lot of other 502 responses before the health check get its 502 and remove the server from rotation. On the other hand, if nginx is stopped first, then HAProxy would simply not able to establish the connection, and straight away remove the server from rotation.
Requirements:
- start/stop/restart nginx -> nothing happens to X
- start/stop/restart X -> nothing happens to nginx
- system shutdown -> shutdown nginx, then shutdown X
Is it doable? Do I have to make X a sysv init script instead?