無限健一 > Unicorn-Manager > Unicorn::Manager::CLI

Download:
Unicorn-Manager-0.006009.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.006009   Source  

NAME ^

Unicorn::Manager::CLI - A Perl interface to the Unicorn webserver

WARNING! ^

This is an unstable development release not ready for production!

VERSION ^

Version 0.006009

SYNOPSIS ^

The Unicorn::Manager::CLI module aimes to provide methods to start, stop and gracefully restart the server. You can add and remove workers on the fly.

TODO: Unicorn::Manager::CLI::Config should provide methods to create config files and offer an OO interface to the config object.

Until now basically only unicorn_rails is supported. This Lib is a quick hack to integrate management of rails apps with rvm and unicorn into perl scripts.

Also some assumption are made about your environment: you use Linux (the module relies on /proc) you use the bash shell your unicorn config is located in your apps root directory every user is running one single application

I will add and improve what is needed though. Requests and patches are welcome.

ATTRIBUTES/CONSTRUCTION ^

Unicorn::Manager::CLI has following attributes:

username

Username of the user that owns the Unicorn process that will be operated on.

The username is a required attribute.

group

Groupname of the Unicorn process. Defaults to the users primary group.

config

A HashRef containing the information to create a Unicorn::Config object. See perldoc Unicon::Config for more information.

proc

A Unicorn::Manager::CLI::Proc object. If omitted it will be created automatically.

uid

The user id matching the given username. Will be set automatically on object creation.

rails

Currently unused flag.

version

Get the Unicorn::Manager::CLI version.

DEBUG

Is a Bool type attribute. Defaults to 'false' and prints additional information if set 'true'.

TODO: Needs to be improved.

Contruction

    my $unicorn = Unicorn::Manager::CLI->new(
        username => 'myuser',
        group    => 'mygroup',
    );

METHODS ^

start

    $unicorn->start({
        config => '/path/to/my/config',
        args => ['-D', '--host 127.0.0.1'],
    });

Parameters are the path to the config file and an optional ArrayRef with additional arguments. These will override the arguments defined in the config file.

This method needs more love and will be rethought and rewritten. Now it assumes the config file is located in the rails apps root directory. It changes into this directory and drops rights to start unicorn.

stop

    $unicorn->stop;

Sends SIGQUIT to the unicorn master. This will gracefully shut down the workers and then quit the master.

If graceful stop will not work SIGKILL will be send.

If no master is running nothing will be happening.

restart

    my $result = $unicorn->restart({ mode => 'hard' });

Mode defaults to 'graceful'.

If mode is set 'hard' graceful restart will be tried first and $unicorn->stop plus $unicorn->start if that fails.

returns true on success, false on error.

reload

    my $result = $unicorn->reload;

Reloads the users unicorn. Reloads the config file. Code changes are reloaded unless app_preload is set.

Basically a SIGHUP will be send to the unicorn master.

read_config

NOT YET IMPLEMENTED

    $unicorn->read_config('/path/to/config');

Reads the configuration from a unicorn config file.

write_config

NOT YET IMPLEMENTED

    $unicorn->make_config('/path/to/config');

Writes the configuration into a unicorn config file.

add_worker

    my $result = $unicorn->add_worker({ num => 3 });

Adds num workers to the users unicorn. num defaults to 1.

remove_worker

    my $result = $unicorn->remove_worker({ num => 3 });

Removes num workers but maximum of workers count -1. num defaults to 1.

query

NOT YET IMPLEMETED.

An interface to query information about running unicorns and users.

AUTHOR ^

Mugen Kenichi, <mugen.kenichi at uninets.eu>

BUGS ^

Report bugs at:

SUPPORT ^

syntax highlighting: