OpenRC zap

By chimo on (updated on )

I don’t remember how I stumbled on this, but today I learned about the `zap` OpenRC command.

From the OpenRC User Guide:

There is a special command zap that makes OpenRC ‘forget’ that a service is started; this is mostly useful to reset a crashed service to stopped state without invoking the (possibly broken) stop function of the service script.

The Gentoo wiki has a usage example:

root # rc-service docker status
 * status: crashed
root # rc-service docker start
 * WARNING: docker has already been started
root # rc-service docker stop
 * Caching service dependencies ...       [ ok ]
 * Stopping docker ...
 * Failed to stop docker                  [ !! ]
 * ERROR: docker failed to stop
# To remedy this situation, zap the service
root # rc-service docker zap