Mojolicious::Plugin::Ubic - Remote ubic admin
#!perl use Mojolicious::Lite; plugin Ubic => { data_dir => '/path/to/ubic/data', default_user => 'ubicadmin', layout => 'my_layout', remote_servers => [...], route => app->routes->route('/something/secure'), service_dir => '/path/to/ubic/service', valid_actions => [...], json => { some => 'default values', }, }; app->start;
See "register" for config description.
This Mojolicious plugin allow you to query status of the running Ubic services and also start/stop/restart/reload/... them.
This is Ubic::Ping::Service on steroids.
POST /service/:service_name/start POST /service/:service_name/reload POST /service/:service_name/restart POST /service/:service_name/stop
Used to control a given service. The actions act like <ubic> from the command line. The return value contain "status". Example:
{"status":"running"}
GET /
Draw a table of services using HTML.
GET /proxy/#to/#service_name/:command
This resource is used to proxy commands to other servers.
GET /services GET /services/:service_name
Returns a json object with the services available and statuses:
{ "multi_service_name": { "child_service_name": { "status":"running" } } }
Is is also possible to ask for "?flat=1" which will result in this response:
{ "services": { "multi_service_name.child_service_name": { "status":"running" } } }
GET /service/:service_name GET /service/:service_name/status
Used to get the status of a given service. Example JSON response:
$app->plugin(Ubic => \%config);
Will register the "ACTIONS" above. Possible %config:
%config
data_dir
Default to "data_dir" in Ubic::Settings.
default_user
Default to "default_user" in Ubic::Settings.
service_dir
Default to "service_dir" in Ubic::Settings.
json
A datastructure (hash-ref) which is included in all the responses. Could contain data such as uptime, hostname, ...
layout
Used to set the layout which the HTML will rendered inside. Default is "ubic" which is defined in this package.
remote_servers
A list of URL which point to other web servers compatible with the API defined in this package. This allow "proxy" to run commands on all servers, including the current. Example:
[ "http://10.1.2.3/secret/ubic/path", "http://10.1.2.4/other/secret/path", ]
route
A Mojolicious::Route object where the "ACTIONS" should be mounted.
command_route
A Mojolicious::Route object where "command" should be mounted. Default is same as "route".
valid_actions
A list of valid actions for "command" to run. Default is:
[ "start", "stop", "reload", "restart" ]
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
To install Rubic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rubic
CPAN shell
perl -MCPAN -e shell install Rubic
For more information on module installation, please visit the detailed CPAN module installation guide.