Commit | Line | Data |
cbff8e52 |
1 | #!/usr/bin/env perl -l |
2 | |
3 | package TestDaemon; |
4 | use Moose; |
5 | with('MooseX::Daemonize'); |
6 | |
7 | before 'daemonize' => sub { |
8 | warn 'forking ' . $$; |
9 | }; |
10 | |
11 | after 'start' => sub { |
12 | return unless $_[0]->is_daemon; |
13 | while (1) { |
14 | local *LOG; |
15 | open LOG, '>>', '/tmp/testdaemon.log'; |
16 | print LOG "$0:$$"; |
17 | close LOG; |
18 | sleep 1; |
19 | } |
20 | }; |
21 | |
22 | package main; |
23 | my $td = new_with_options TestDaemon( pidbase => '/tmp' ); |
24 | use YAML; |
25 | warn Dump $td->pidfile; |
26 | warn $td->check; |
27 | print "PARENT: $$"; |
28 | print 'PID: ' . $td->get_pid; |
29 | print $td->start; |