Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dex4er/thrall

a simple PSGI/Plack server that uses threads
https://github.com/dex4er/thrall

Last synced: about 2 months ago
JSON representation

a simple PSGI/Plack server that uses threads

Awesome Lists containing this project

README

        

NAME

thrall - Simple PSGI/Plack HTTP server that uses threads

SYNOPSIS

$ thrall --max-workers=20 --max-reqs-per-child=100 app.psgi

$ thrall --port=80 --ipv6=1 app.psgi

$ thrall --port=443 --ssl=1 --ssl-key-file=file.key --ssl-cert-file=file.crt app.psgi

$ thrall --socket=/tmp/thrall.sock app.psgi

DESCRIPTION

Thrall is a standalone HTTP/1.1 server with keep-alive support. It uses
threads instead pre-forking, so it works correctly on Windows. It is a
pure-Perl implementation that doesn't require any XS package.

Thrall was started as a fork of Starlet server. It has almost the same
code as Starlet and it was adapted to use threads instead fork().

SEE ALSO

Starlight, Starlet, Starman

LIMITATIONS

See "BUGS AND LIMITATIONS" in threads and "Thread-Safety of System
Libraries" in perlthrtut to read about limitations for PSGI
applications started with Thrall and check if you encountered a known
problem.

Especially, PSGI applications should avoid: changing the current
working directory, catching signals, and starting new processes.
Environment variables might (Linux, Unix) or might not (Windows) be
shared between threads.

Thrall is very slow on the first request for each thread. It is because
spawning new threads is slow in Perl itself. Thrall is very fast on
another request and generally is faster than any implementation which
uses fork.

BUGS

There is a problem with Perl threads implementation which occurs on
Windows. Some requests can fail with the message:

failed to set socket to nonblocking mode:An operation was attempted
on something that is not a socket.

or

Bad file descriptor at (eval 24) line 4.

Cygwin version seems to be correct.

This problem was introduced in Perl 5.16 and fixed in Perl 5.19.5.

See https://rt.perl.org/rt3/Public/Bug/Display.html?id=119003 and
https://github.com/dex4er/Thrall/issues/5 for more information about
this issue.

MacOS

MacOS High Sierra and newer shows error:

objc[12345]: +[__NSCFConstantString initialize] may have been in
progress in another thread when fork() was called. objc[12345]:
+[__NSCFConstantString initialize] may have been in progress in
another thread when fork() was called. We cannot safely call it or
ignore it in the fork() child process. Crashing instead. Set a
breakpoint on objc_initializeAfterForkError to debug.

This error is caused by an added security to restrict multithreading.

To override the limitation, run export
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES before using this server.

Reporting

If you find the bug or want to implement new features, please report it
at https://github.com/dex4er/Thrall/issues

The code repository is available at http://github.com/dex4er/Thrall

AUTHORS

Piotr Roszatycki

Based on Starlet by:

Kazuho Oku

miyagawa

kazeburo

Some code based on Plack:

Tatsuhiko Miyagawa

Some code based on Net::Server::Daemonize:

Jeremy Howard

Paul Seamons

LICENSE

Copyright (c) 2013-2017, 2023 Piotr Roszatycki .

This is free software; you can redistribute it and/or modify it under
the same terms as perl itself.

See http://dev.perl.org/licenses/artistic.html