Hi group,
I just want to run bash script and forget about it.
I was trying just put it in backgrount with '&' sign
`sh runImportPhen &`;
but it doesn't work.
Because of it I'm trying with Mojo::IOLoop
--------Pdataexport.pm----------------------
package MyApp::Pdataexport;
use base 'Mojolicious::Controller';
use Date::Calc qw(:all);
use File::Path qw(make_path remove_tree);
use Mojo::IOLoop;
sub importExternalPhenotypes{
...prepare runImportPhen.sh script...
my $delay = Mojo::IOLoop->delay;
$delay->steps(
sub {
my $delay = shift;
`sh runImportPhen `;
}
);
$self->redirect_to('/pdataexport');
}
code above also doesn't work. When I click buton which run importExternalPhenotypes subroutine I need to wait until bash script ends work - (web page hangs until it finisz)
I was trying also with
sub importExternalPhenotypes{
...prepare runImportPhen.sh script...
my $subprocess = Mojo::IOLoop::Subprocess->new;
$subprocess->run(
sub {
my $subprocess = shift;
`sh runImportPhen `;
}
$self->redirect_to('/pdataexport');
);
but it crash...
Can you please provide some simple example code how it should be done?
Thank you,
tj