NAME

Mojolicious::Plugin::Ubic - Remote ubic admin

SYNOPSIS

#!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.

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.

ACTIONS

command

POST /:service_name/start
POST /:service_name/reload
POST /:service_name/restart
POST /: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"}

index

Draw a table of services using HTML.

proxy

This resource is used to proxy commands to other servers.

services

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"
    }
  }
}

status

GET /:service_name
GET /:service_name/status

Used to get the status of a given service. Example JSON response:

{"status":"running"}

METHODS

register

$app->plugin(Ubic => \%config);

Will register the "ACTIONS" above. Possible %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" ]

COPYRIGHT

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org

1 POD Error

The following errors were encountered while parsing the POD:

Around line 309:

Expected '=item *'