Question

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 is a script that raise the server is has the following script:

#!/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:

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

it works.

what may be the problem here?

Thanks a lot.

Was it helpful?

Solution

I found the solution :-) - the problem was with the nohup command - it was missing the:

2>nohup.out

I added it and it works now.

Thanks everybody.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top