是否建议使用Perl的Taint模式开发Plack应用程序(中间件)?
如果是,如何在Tainted模式下启动plackup和/或Starman?在简单的CGI脚本中,这很容易通过shebang行完成。
perl -T /path/to/{plackup|starman}
是否能胜任此工作?还是有其他推荐的方法?还是不建议使用?
关于Plack+Taint模式组合的任何想法、指针、文章?
通常我们不建议人们在污点模式下开发Plack应用程序,因为我个人不相信污点模式的有用性。
Plack的核心工具,如plackup和Plack :: Utli,特别是与污点模式不兼容,因为它需要将给定的.psgi文件编译为源代码。如果您真的想在污点模式下开发应用程序,则必须绕过plackup并使用Plack :: Handler或Plack :: Loader。
绕过plackup很简单, 我可以给你一个fastcgi的例子,但是使用starman也应该有可能做到 忘记.psgi文件,使用一个普通的启动脚本:
my $app = sub {
my $env = shift;
#...
}
#read the pid file, check for an old process, kill the old process...
#...
#choose a psgi Server impl.
#i prefere fcgi
my $manager = new FCGI::ProcManager::MaxRequests({
'max_requests'=>100,
'pid_fname'=>$pid_file,
'n_processes'=> 3,
'pm_title'=> $name
});
my $server = Plack::Handler::FCGI->new(
'listen'=>[$socket],
'detach' => 1,
'manager' => $manager
); #或使用Plack::Loader加载服务器
#运行您的应用程序 $server->run($app);
然后使用taintmode perl -T启动您的startup.pl脚本