What's a good method to trigger apache restart after .deb installation?
I have several custom .debs that I've built. They all depend on apache and after up开发者_运维问答grade of any package apache needs to be restarted.
Restarting apache naively from the postinst I get a restart for each package I upgrade, which is really slow. Does anyone know if there's a good way to avoid that? Dpkg triggers seems to be the right approach but I can't seem to find much in the way of documentation. Does apache define its own trigger to activate. If so, how do I call it?
Yes, dpkg triggers would be the right approach here. And no, I don't believe that there is any preexisting trigger-fu to solve this problem for you.
At its most simple, your setup might consist of something like the following:
- Some common package, on which all of your apache-using debs will Depend. Let's call it "apache-coordination".
- apache-coordination's
DEBIAN/triggers
file should contain a line likeinterest apache-coordination-reload
. - apache-coordination's
postinst
should handle the case where it gets called with the argument "triggered
" and where "apache-coordination-reload
" is somewhere in the second argument, by performing the actual apache reload or restart (ideally throughinvoke-rc.d
or something similar, so that runlevels are respected). - Your other packages should activate the
apache-coordination-reload
trigger when appropriate. This could be done by shippingDEBIAN/triggers
files for each of them containingactivate apache-coordination-reload
.
精彩评论