#! /usr/bin/perl
# PODNAME: tapper-mcp-daemonize
# ABSTRACT: cmdline frontend to Tapper::MCP::Master/daemonize

use strict;
use warnings;

# TODO: redirect STDERR/STDOUT

use File::Spec::Functions 'tmpdir';
use File::Temp "tempfile";
use Tapper::MCP::Master;
use App::Daemon 'daemonize';

my ($tmpfh, $tmpfile) = tempfile("tapper-mcp-daemon.log-XXXXX", UNLINK => 1);
$App::Daemon::as_user = "root";
$App::Daemon::logfile = $ENV{HARNESS_ACTIVE} ? $tmpfile : "/var/log/tapper-mcp-daemon.log";
$App::Daemon::pidfile = tmpdir()."/tapper-mcp-daemon.pid";
daemonize();
my $mcp = new Tapper::MCP::Master;
$mcp->run;

__END__
=pod

=encoding utf-8

=head1 NAME

tapper-mcp-daemonize - cmdline frontend to Tapper::MCP::Master/daemonize

=head1 AUTHOR

AMD OSRC Tapper Team <tapper@amd64.org>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2012 by Advanced Micro Devices, Inc..

This is free software, licensed under:

  The (two-clause) FreeBSD License

=cut

