Unicorn::Manager::CLI - A Perl interface to the Unicorn webserver
This is an unstable development release not ready for production!
Version 0.006009
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.
Unicorn::Manager::CLI has following attributes:
Username of the user that owns the Unicorn process that will be operated on.
The username is a required attribute.
Groupname of the Unicorn process. Defaults to the users primary group.
A HashRef containing the information to create a Unicorn::Config object. See perldoc Unicon::Config for more information.
A Unicorn::Manager::CLI::Proc object. If omitted it will be created automatically.
The user id matching the given username. Will be set automatically on object creation.
Currently unused flag.
Get the Unicorn::Manager::CLI version.
Is a Bool type attribute. Defaults to 'false' and prints additional information if set 'true'.
TODO: Needs to be improved.
my $unicorn = Unicorn::Manager::CLI->new( username => 'myuser', group => 'mygroup', );
$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.
$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.
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.
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.
NOT YET IMPLEMENTED
$unicorn->read_config('/path/to/config');
Reads the configuration from a unicorn config file.
$unicorn->make_config('/path/to/config');
Writes the configuration into a unicorn config file.
my $result = $unicorn->add_worker({ num => 3 });
Adds num workers to the users unicorn. num defaults to 1.
my $result = $unicorn->remove_worker({ num => 3 });
Removes num workers but maximum of workers count -1. num defaults to 1.
NOT YET IMPLEMETED.
An interface to query information about running unicorns and users.
Mugen Kenichi, <mugen.kenichi at uninets.eu>
<mugen.kenichi at uninets.eu>
Report bugs at:
Unicorn::Manager::CLI issue tracker
https://github.com/mugenken/Unicorn/issues
support at uninets.eu
Technical support
To install Unicorn::Manager::CLI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Unicorn::Manager::CLI
CPAN shell
perl -MCPAN -e shell install Unicorn::Manager::CLI
For more information on module installation, please visit the detailed CPAN module installation guide.