[英]How to deploy perl dancer app with cgi and calling external scripts?
I have had a webapp using CGI implementation. 我有一个使用CGI实现的webapp。 It basically uses system() calls to launch other programs and the results will be rendered in html.
它基本上使用system()调用来启动其他程序,并且结果将以html呈现。
Now, I am trying to implement it using Dancer. 现在,我正在尝试使用Dancer来实现它。 In order to run these external programs, I created a "scripts" directory in /MyApp, so it's like /MyApp/scripts.
为了运行这些外部程序,我在/ MyApp中创建了一个“ scripts”目录,因此它类似于/ MyApp / scripts。 I put all my other scripts there, which will be called in a route handler.
我将所有其他脚本放在此处,这些脚本将在路由处理程序中调用。
get '/analysis' => sub {
if (session('user') && session('logged_in')) {
open FH, "<", "./scripts/test.out";
my $msg = <FH>;
close FH;
chdir ("./scripts");
system("call sth"); #call external programs to generate a "test.png"
my $err;
copy ("test.png", "../public/images/test.png") || ($err = "cannot copy"); #copy the "test.png" to public/images directory, so the
my $img = "test.png";
template 'analysis',{msg => $msg, img => $img, err => $err};
}
else {
return redirect '/'
}
}; };
However, I can launch this app successfully as a standalone or using plackup/starman. 但是,我可以独立或使用plackup / starman成功启动此应用程序。 But I can not deploy it with CGI.
但是我不能用CGI部署它。 I did every step using dancer's doc regarding cgi deployment.
我使用舞者的文档做有关CGI部署的每一步。 I can successfully using cgi to launch dancer's example app.
我可以成功地使用cgi启动舞者的示例应用程序。 but when I tried to launch my own as above, I always got the error:
但是当我尝试如上所述启动自己的应用程序时,总是出现错误:
app directory '/home/tester/MyApp/bin/..' isn't writable/executable and can't chmod it at /usr/local/share/perl/5.14.2/Dancer/Logger.pm line 16, referer:localhost 应用程序目录“ / home / tester / MyApp / bin / ..”不可写/可执行,并且无法在/usr/local/share/perl/5.14.2/Dancer/Logger.pm第16行进行chmod引用:本地主机
It seems a permission problem, but I don't know how to fix it. 似乎是权限问题,但我不知道如何解决。 Is there a better way to launch an external program from route handler?
是否有更好的方法从路由处理程序启动外部程序? where should I store these external programs, thus they can be executed by the dancer app when it was deployed as CGI.
我应该将这些外部程序存储在哪里,以便在将Dancer应用程序部署为CGI时可以由该应用程序执行。
Could anyone help me? 有人可以帮我吗? Thanks.
谢谢。
Xiaokuan 小宽
Dancer::Logger::File
documentation says: Dancer::Logger::File
文档说:
It's possible to specify a logs directory with the log_path option.
可以使用log_path选项指定日志目录。
setting log_path => $dir;
Simply add a line to your (production.yml) environment file: 只需在您的(production.yml)环境文件中添加一行:
log_path: /var/log/dancer/myapp/
and make this path writable to www-data
. 并使该路径可
www-data
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.