Ubic::Service::InitScriptWrapper - represent any /etc/init.d/ script as ubic service
version 0.02
# in /etc/ubic/service/my-nginx use Ubic::Service::InitScriptWrapper; Ubic::Service::InitScriptWrapper->new('nginx'); # map /etc/init.d/nginx to 'my-nginx' ubic service
This module lets you turn any LSB-compliant init script into ubic service.
Note that this is completely different from Ubic::Run. Ubic::Run lets you turn ubic service to init script. This module does the reverse thing.
Ubic::Run
There are several reasons why this module can be useful.
First, it allows you to use all ubic features (watchdog, pretty CLI interface, persistent service states) without changing any of your code.
Second, some daemons don't provide a way not to detach them from a terminal. Classic init scripts usually use start-stop-daemon to start these daemons. Ubic::Daemon and Ubic::Service::SimpleDaemon can't be used to start such processes. You could write system('start-stop-daemon ...') in your ubic service code, but if you already got a working init script, why bother?
start-stop-daemon
Ubic::Daemon
Ubic::Service::SimpleDaemon
system('start-stop-daemon ...')
Init script must conform to LSB specification (http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html).
At the very least, it must exit with zero exit code on successful start, stop and status commands, and with non-zero exit code on unsuccessful status command.
This module doesn't distinguish broken and not running states yet. It interprets any non-zero status code as not running.
broken
not running
If $init_script_name contains /, it'll be interpreted as a filename.
$init_script_name
/
Otherwise, /etc/init.d/$init_script_name will be used.
/etc/init.d/$init_script_name
Vyacheslav Matyukhin <mmcleric@yandex-team.ru>
This software is copyright (c) 2012 by Yandex LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Ubic::Service::InitScriptWrapper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ubic::Service::InitScriptWrapper
CPAN shell
perl -MCPAN -e shell install Ubic::Service::InitScriptWrapper
For more information on module installation, please visit the detailed CPAN module installation guide.