#!/usr/bin/env perl
package ubic_daemon;
BEGIN {
  $ubic_daemon::VERSION = '1.27';
}

# ABSTRACT: daemonize any binary

use strict;
use warnings;


use Getopt::Long 2.33;
use Pod::Usage;

use Ubic::Daemon qw(start_daemon);

my $name;
my $pid_dir = '/var/lib/ubic/ubic-daemon';

return 1 if caller();

GetOptions(
    'name=s'    => \$name,
    'pid-dir=s' => \$pid_dir,
) or pod2usage(2);
pod2usage(2) unless @ARGV == 1;
pod2usage(2) unless defined $name;

start_daemon({
    name => $name,
    pidfile => "$pid_dir/$name",
    bin => shift(@ARGV),
});


__END__
=pod

=head1 NAME

ubic_daemon - daemonize any binary

=head1 VERSION

version 1.27

=head1 SYNOPSIS

    ubic-daemon --name=sleep 'sleep 1000'

=head1 DECSRIPTION

This program can be used to easily daemonize any binary.

=head1 SEE ALSO

L<Ubic::Daemon>

There is a similar program named C<start-stop-daemon> in Debian.and some other Linux distributions which does daemonization and have some other powerful features.

=head1 AUTHOR

Vyacheslav Matyukhin <mmcleric@yandex-team.ru>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.

=cut

