Makefile.PL | 2 +-
public-inbox-httpd | 129 -----------------------------------------------------
public-inbox-index => script/public-inbox-index | 0
public-inbox-init => script/public-inbox-init | 0
public-inbox-learn => script/public-inbox-learn | 0
public-inbox-mda => script/public-inbox-mda | 0
public-inbox-nntpd => script/public-inbox-nntpd | 0
public-inbox.cgi => script/public-inbox.cgi | 0
script/public-inbox-httpd | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/Makefile.PL b/Makefile.PL
index 621baf60d3ace4ffb474144543ef3e567e28519a..85822031d59da02ef0832b6df79eb99458e544f5 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -3,7 +3,7 @@ # Copyright (C) 2013-2015 all contributors
# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
use strict;
use ExtUtils::MakeMaker;
-my @EXE_FILES = split("\n", `git ls-files 'public-inbox*' 2>/dev/null`);
+my @EXE_FILES = split("\n", `git ls-files 'script/*' 2>/dev/null`);
my $PM_FILES = `git ls-files lib '*.pm' 2>/dev/null`;
$PM_FILES =~ tr/\n/ /;
diff --git a/public-inbox-httpd b/public-inbox-httpd
deleted file mode 100644
index 6109af01a62cdad79fdd11a3bdeea9652033f94d..0000000000000000000000000000000000000000
--- a/public-inbox-httpd
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/usr/bin/perl -w
-# Copyright (C) 2016 all contributors
-# License: AGPL-3.0+
-#
-# Standalone HTTP server for public-inbox.
-use strict;
-use warnings;
-use Plack::Util;
-use PublicInbox::Daemon;
-use PublicInbox::HTTP;
-use Plack::Request;
-use Plack::Builder;
-my %httpds;
-my $app;
-my $refresh = sub {
- if (@ARGV) {
- eval { $app = Plack::Util::load_psgi(@ARGV) };
- if ($@) {
- die $@,
-"$0 runs in /, command-line paths must be absolute\n";
- }
- } else {
- require PublicInbox::WWW;
- PublicInbox::WWW->preload;
- my $www = PublicInbox::WWW->new;
- $app = eval {
- my $deflate_types = eval {
- require Plack::Middleware::Deflater;
- [ 'text/html', 'text/plain',
- 'application/atom+xml' ]
- };
- builder {
- enable 'Chunked';
- if ($deflate_types) {
- enable 'Deflater',
- content_type => $deflate_types
- }
- enable 'ReverseProxy';
- enable 'Head';
- sub { $www->call(@_) };
- };
- };
- }
-};
-
-daemon_run('0.0.0.0:8080', $refresh,
- sub ($$$) { # post_accept
- my ($client, $addr, $srv) = @_;
- my $fd = fileno($srv);
- my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app);
- PublicInbox::HTTP->new($client, $addr, $h),
- });
-
-1;
-
-package PublicInbox::HTTPD::Async;
-use strict;
-use warnings;
-use base qw(Danga::Socket);
-use fields qw(cb);
-
-sub new {
- my ($class, $io, $cb) = @_;
- my $self = fields::new($class);
- $io->blocking(0);
- $self->SUPER::new($io);
- $self->{cb} = $cb;
- $self->watch_read(1);
- $self;
-}
-
-sub event_read { $_[0]->{cb}->() }
-sub event_hup { $_[0]->{cb}->() }
-sub event_err { $_[0]->{cb}->() }
-sub sysread { shift->{sock}->sysread(@_) }
-
-1;
-
-package PublicInbox::HTTPD;
-use strict;
-use warnings;
-use Plack::Util;
-
-sub pi_httpd_async {
- my ($io, $cb) = @_;
- PublicInbox::HTTPD::Async->new($io, $cb);
-}
-
-sub new {
- my ($class, $sock, $app) = @_;
- my $n = getsockname($sock) or die "not a socket: $sock $!\n";
- my ($port, $addr);
- if (length($n) >= 28) {
- require Socket6;
- ($port, $addr) = Socket6::unpack_sockaddr_in6($n);
- } else {
- ($port, $addr) = Socket::unpack_sockaddr_in($n);
- }
-
- my %env = (
- REMOTE_HOST => '',
- REMOTE_PORT => 0,
- SERVER_NAME => $addr,
- SERVER_PORT => $port,
- SCRIPT_NAME => '',
- 'psgi.version' => [ 1, 1 ],
- 'psgi.errors' => \*STDERR,
- 'psgi.url_scheme' => 'http',
- 'psgi.nonblocking' => Plack::Util::TRUE,
- 'psgi.streaming' => Plack::Util::TRUE,
- 'psgi.run_once' => Plack::Util::FALSE,
- 'psgi.multithread' => Plack::Util::FALSE,
- 'psgi.multiprocess' => Plack::Util::TRUE,
- 'psgix.harakiri'=> Plack::Util::FALSE,
- 'psgix.input.buffered' => Plack::Util::TRUE,
- 'pi-httpd.async' => do {
- no warnings 'once';
- *pi_httpd_async
- },
- );
- bless {
- err => \*STDERR,
- out => \*STDOUT,
- app => $app,
- env => \%env,
- }, $class;
-}
-
-1;
diff --git a/public-inbox-index b/script/public-inbox-index
rename from public-inbox-index
rename to script/public-inbox-index
diff --git a/public-inbox-init b/script/public-inbox-init
rename from public-inbox-init
rename to script/public-inbox-init
diff --git a/public-inbox-learn b/script/public-inbox-learn
rename from public-inbox-learn
rename to script/public-inbox-learn
diff --git a/public-inbox-mda b/script/public-inbox-mda
rename from public-inbox-mda
rename to script/public-inbox-mda
diff --git a/public-inbox-nntpd b/script/public-inbox-nntpd
rename from public-inbox-nntpd
rename to script/public-inbox-nntpd
diff --git a/public-inbox.cgi b/script/public-inbox.cgi
rename from public-inbox.cgi
rename to script/public-inbox.cgi
diff --git a/script/public-inbox-httpd b/script/public-inbox-httpd
new file mode 100755
index 0000000000000000000000000000000000000000..6109af01a62cdad79fdd11a3bdeea9652033f94d
--- /dev/null
+++ b/script/public-inbox-httpd
@@ -0,0 +1,129 @@
+#!/usr/bin/perl -w
+# Copyright (C) 2016 all contributors
+# License: AGPL-3.0+
+#
+# Standalone HTTP server for public-inbox.
+use strict;
+use warnings;
+use Plack::Util;
+use PublicInbox::Daemon;
+use PublicInbox::HTTP;
+use Plack::Request;
+use Plack::Builder;
+my %httpds;
+my $app;
+my $refresh = sub {
+ if (@ARGV) {
+ eval { $app = Plack::Util::load_psgi(@ARGV) };
+ if ($@) {
+ die $@,
+"$0 runs in /, command-line paths must be absolute\n";
+ }
+ } else {
+ require PublicInbox::WWW;
+ PublicInbox::WWW->preload;
+ my $www = PublicInbox::WWW->new;
+ $app = eval {
+ my $deflate_types = eval {
+ require Plack::Middleware::Deflater;
+ [ 'text/html', 'text/plain',
+ 'application/atom+xml' ]
+ };
+ builder {
+ enable 'Chunked';
+ if ($deflate_types) {
+ enable 'Deflater',
+ content_type => $deflate_types
+ }
+ enable 'ReverseProxy';
+ enable 'Head';
+ sub { $www->call(@_) };
+ };
+ };
+ }
+};
+
+daemon_run('0.0.0.0:8080', $refresh,
+ sub ($$$) { # post_accept
+ my ($client, $addr, $srv) = @_;
+ my $fd = fileno($srv);
+ my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app);
+ PublicInbox::HTTP->new($client, $addr, $h),
+ });
+
+1;
+
+package PublicInbox::HTTPD::Async;
+use strict;
+use warnings;
+use base qw(Danga::Socket);
+use fields qw(cb);
+
+sub new {
+ my ($class, $io, $cb) = @_;
+ my $self = fields::new($class);
+ $io->blocking(0);
+ $self->SUPER::new($io);
+ $self->{cb} = $cb;
+ $self->watch_read(1);
+ $self;
+}
+
+sub event_read { $_[0]->{cb}->() }
+sub event_hup { $_[0]->{cb}->() }
+sub event_err { $_[0]->{cb}->() }
+sub sysread { shift->{sock}->sysread(@_) }
+
+1;
+
+package PublicInbox::HTTPD;
+use strict;
+use warnings;
+use Plack::Util;
+
+sub pi_httpd_async {
+ my ($io, $cb) = @_;
+ PublicInbox::HTTPD::Async->new($io, $cb);
+}
+
+sub new {
+ my ($class, $sock, $app) = @_;
+ my $n = getsockname($sock) or die "not a socket: $sock $!\n";
+ my ($port, $addr);
+ if (length($n) >= 28) {
+ require Socket6;
+ ($port, $addr) = Socket6::unpack_sockaddr_in6($n);
+ } else {
+ ($port, $addr) = Socket::unpack_sockaddr_in($n);
+ }
+
+ my %env = (
+ REMOTE_HOST => '',
+ REMOTE_PORT => 0,
+ SERVER_NAME => $addr,
+ SERVER_PORT => $port,
+ SCRIPT_NAME => '',
+ 'psgi.version' => [ 1, 1 ],
+ 'psgi.errors' => \*STDERR,
+ 'psgi.url_scheme' => 'http',
+ 'psgi.nonblocking' => Plack::Util::TRUE,
+ 'psgi.streaming' => Plack::Util::TRUE,
+ 'psgi.run_once' => Plack::Util::FALSE,
+ 'psgi.multithread' => Plack::Util::FALSE,
+ 'psgi.multiprocess' => Plack::Util::TRUE,
+ 'psgix.harakiri'=> Plack::Util::FALSE,
+ 'psgix.input.buffered' => Plack::Util::TRUE,
+ 'pi-httpd.async' => do {
+ no warnings 'once';
+ *pi_httpd_async
+ },
+ );
+ bless {
+ err => \*STDERR,
+ out => \*STDOUT,
+ app => $app,
+ env => \%env,
+ }, $class;
+}
+
+1;