iseif has asked for the wisdom of the Perl Monks concerning the following question:

Hey,

I have a mojolicio server on a machine where I connect to it from another machine. I have a script that checks if the mojolicio is up - and run it if it is not running. 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 contains the following code that raise the server:

#!/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://*:3 +030');

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:

ssh root@hostname 'cd /server_path/; (usr/bin/perl server_file );'

it works.

What i'm doing wrong here?

Thanks a lot.

Replies are listed 'Best First'.
Re: Run Perl Mojolicio Server from SSH
by Anonymous Monk on Feb 06, 2014 at 10:43 UTC

    What i'm doing wrong here?

    Omitting details

    Like what server_file does

      The server file is a script that raise the server is has the following code:

      #!/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://*:3 +030');

        What do you expect  'http://*:3030' to resolve to?

        What does the logs say it actually resolves to?

        How is that different from the address you're typing in your browser?