forked from unbit/uwsgi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.psgi
65 lines (54 loc) · 1.16 KB
/
test.psgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use strict;
use warnings;
my $rpc_value = uwsgi::call('hello', 'foo', 'bar', 'test');
if ($rpc_value) {
print "rpc value = ".$rpc_value."\n";
}
my $one = sub {
my $env = shift;
sleep(1);
print "one\n";
};
my $two = sub {
my $env = shift;
sleep(1);
print "two\n";
};
my $four = sub {
my $signum = shift;
print "i am signal ".$signum."\n" ;
};
uwsgi::register_signal(17, '', $four);
uwsgi::register_signal(30, '', $two);
my $three = sub {
my $env = shift;
sleep(1);
print "three\n";
};
my $app = sub {
my $env = shift;
uwsgi::signal(17);
uwsgi::signal(30);
if ($env->{'psgix.cleanup'}) {
print "cleanup supported\n";
push @{$env->{'psgix.cleanup.handlers'}}, $one;
push @{$env->{'psgix.cleanup.handlers'}}, $two;
push @{$env->{'psgix.cleanup.handlers'}}, $three;
}
uwsgi::cache_set("key1", "val1");
if ($rpc_value) {
print uwsgi::call('hello')."\n";
}
print 'pid '.$$."\n";
return [
'200',
[ 'Content-Type' => 'text/plain' ],
[ "Hello World\r\n", $env->{'REQUEST_URI'}, uwsgi::cache_get('key1'), uwsgi::call('hello') ],
];
};
uwsgi::postfork(sub {
print "forked !!!\n";
});
uwsgi::atexit(sub {
print "exited\n";
});