diff options
author | Eric Wong <e@80x24.org> | 2020-12-15 09:03:34 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-12-19 09:32:08 +0000 |
commit | 504774acd5236653cdeafb536be95fbfb147258f (patch) | |
tree | 8dd27060a8710f6aa6175c740bda5662f068adbb /script | |
parent | d42172638f5479f76e73470ad48a679100c3e0d5 (diff) | |
download | public-inbox-504774acd5236653cdeafb536be95fbfb147258f.tar.gz |
This allows us to rely on FD_CLOEXEC being set on pipes from prove(1), so forgetting `daemon-stop' won't cause tests to hang. Unfortunately, daemon tests will be slower with this.
Diffstat (limited to 'script')
-rwxr-xr-x | script/lei | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -21,13 +21,19 @@ if (eval { require IO::FDPass; 1 }) { # use daemon to reduce load time }; my $sock = IO::Socket::UNIX->new(Peer => $path, Type => SOCK_STREAM); unless ($sock) { # start the daemon if not started - my $err = $!; - require PublicInbox::LeiDaemon; - $err = PublicInbox::LeiDaemon::lazy_start($path, $err); + my $err = $! + 0; + my $env = { PERL5LIB => join(':', @INC) }; + my $cmd = [ $^X, qw[-MPublicInbox::LeiDaemon + -E PublicInbox::LeiDaemon::lazy_start(@ARGV)], + $path, $err ]; + require PublicInbox::Spawn; + waitpid(PublicInbox::Spawn::spawn($cmd, $env), 0); + warn "lei-daemon exited with \$?=$?\n" if $?; + # try connecting again anyways, unlink+bind may be racy $sock = IO::Socket::UNIX->new(Peer => $path, Type => SOCK_STREAM) // die - "connect($path): $! (bind($path): $err)"; + "connect($path): $! (after attempted daemon start)"; } my $pwd = $ENV{PWD}; my $cwd = cwd(); |