[英]Run Perl Mojolicio Server from SSH
I have a mojolicio server on a machine where I connect to it from another machine. 我从另一台计算机连接到一台计算机上有一台mojolicio服务器。 I have a script that checks if the mojolicio is up - and run it if it is not running.
我有一个脚本,用于检查mojolicio是否已启动-如果未运行,请运行它。 I use the following command line to run the server:
我使用以下命令行来运行服务器:
ssh root@hostname 'cd /server_path/; (nohup /usr/bin/perl server_file >nohup.out &);'
The server_file is a script that raise the server is has the following script: server_file是引发服务器的脚本,具有以下脚本:
#!/usr/bin/env perl
use Mojo::Base -strict;
use File::Basename 'dirname';
use File::Spec::Functions qw(catdir splitdir);
# Source directory has precedence
my @base = (splitdir(dirname(__FILE__)), '..');
my $lib = join('/', @base, 'lib');
-e catdir(@base, 't') ? unshift(@INC, $lib) : push(@INC, $lib);
# Start commands for application
require Mojolicious::Commands;
Mojolicious::Commands->start_app('MyServer', 'daemon','-l','http://*:3030');
If the server is down and I run this command - I see in the machine that the server is up and running and it listening to the port it configured to listen to. 如果服务器已关闭并且我运行此命令-我在机器上看到服务器已启动并正在运行,并且正在侦听配置为侦听的端口。 Now, if I try to connect to the server from the browser it don't not load.
现在,如果我尝试从浏览器连接到服务器,则不会加载。 It stuck on loading and in the end I got page not found.
它在加载时卡住了,最后我找不到页面。 But if I run the same command from the server itself it works and I can load the homepage after it runs.
但是,如果我从服务器本身运行相同的命令,它将起作用,并且可以在运行后加载主页。
I found the problem.. 我发现了问题..
If I use the nohup with the ssh then the server somehow won't be reachable - but when I run the server without the nohup as for example - using the following code: 如果我将nohup与ssh一起使用,则服务器将无法访问-但例如,当我在没有nohup的情况下运行服务器时,请使用以下代码:
ssh root@hostname 'cd /server_path/; (usr/bin/perl server_file );'
it works. 有用。
what may be the problem here? 这可能是什么问题?
Thanks a lot. 非常感谢。
I found the solution :-) - the problem was with the nohup command - it was missing the: 我找到了解决方案:-)-问题出在nohup命令上-它丢失了:
2>nohup.out
I added it and it works now. 我添加了它,现在可以使用了。
Thanks everybody. 谢谢大家。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.