summaryrefslogtreecommitdiffstats
path: root/network/fcgiwrap/spawn-fcgi
diff options
context:
space:
mode:
author Zhu Qun-Ying <zhu.qunying@gmail.com>2014-11-08 02:13:47 +0700
committer Willy Sudiarto Raharjo <willysr@slackbuilds.org>2014-11-08 06:30:19 +0700
commit79a8f439b6090adb9770a78d173f7ed5bdcf570a (patch)
treec3e110abdcc6c3a566e5d736980d3099724ff636 /network/fcgiwrap/spawn-fcgi
parent0e6711fd438e1218dcf944ba81cc969dd77c13be (diff)
downloadslackbuilds-79a8f439b6090adb9770a78d173f7ed5bdcf570a.tar.gz
slackbuilds-79a8f439b6090adb9770a78d173f7ed5bdcf570a.tar.xz
network/fcgiwrap: Added (Simple FastCGI wrapper).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network/fcgiwrap/spawn-fcgi')
-rw-r--r--network/fcgiwrap/spawn-fcgi29
1 files changed, 29 insertions, 0 deletions
diff --git a/network/fcgiwrap/spawn-fcgi b/network/fcgiwrap/spawn-fcgi
new file mode 100644
index 0000000000..829d05504a
--- /dev/null
+++ b/network/fcgiwrap/spawn-fcgi
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings FATAL => qw( all );
+
+use IO::Socket::UNIX;
+
+my $bin_path = '/usr/sbin/fcgiwrap';
+my $socket_path = $ARGV[0] || '/tmp/cgi.sock';
+my $num_children = $ARGV[1] || 1;
+
+close STDIN;
+
+unlink $socket_path;
+my $socket = IO::Socket::UNIX->new(
+ Local => $socket_path,
+ Listen => 100,
+);
+
+die "Cannot create socket at $socket_path: $!\n" unless $socket;
+
+for (1 .. $num_children) {
+ my $pid = fork;
+ die "Cannot fork: $!" unless defined $pid;
+ next if $pid;
+
+ exec $bin_path;
+ die "Failed to exec $bin_path: $!\n";
+}