I'm running a perl Dancer application using Starman via plack (hopefully that is describing things correctly), and mostly this has been a painless experience. I've just recently been trying to get sessions working (really simple stuff - I just want to store a couple of strings, and I am using session: "Simple"), and I am running into really strange issues when running Starman with multiple workers.
Using the following very simple code (at the bottom) results in the following:
Standalone app: Works fine - counter increments when you click on it.
Starman - 1 worker: Works fine
Starman - 2+ workers: The session appears to exist for approximately 1 second, and is subsequently destroyed - the counter always "expires" after a very very short period of time. It doesn't appear to be a worker-specific session, it just resets to nothing. If you hammer the link more than once a second, it increments normally forever (or for as long as I could be bothered to test it).
Am I doing anything wrong, or is this just not going to work? It isn't terribly critical, but it would be nice to be able to get simple sessions working.
Thanks,
Dave
##
## Code to reproduce via:
## plackup -D -E env -s Starman --workers=3 -p 3000 -a myapp.pl
##
get '/sessiontest' => sub {
return(&sessiontest());
};
sub sessiontest {
my $testcounter = session 'testcounter' || 0;
$testcounter++;
session 'testcounter' => $testcounter;
info "SESSION COUNTER($testcounter)";
my $return = <<EOF;
<html>
<body>
<a href=\"/sessiontest\">$testcounter</a>
</body>
</html>
EOF
return($return);
}