Re: [Mojolicious] How to launch gvim reliably within a mojo app?

2020-03-09 Thread Matthew Pressly
Using Mojo::IOLoop->subprocess is working for me. Here's what I have now 
(adapted from the example):


get '/edit' => sub {
    my $c = shift;
    Mojo::IOLoop->subprocess(
    sub {
    my $subprocess = shift;
    my $result = `/usr/bin/gvim $tc_file 2>&1`;
    return;
    },
    sub {
    my ($subprocess, $err, @results) = @_;
    say "Subprocess error: $err" and return if $err;
    }
    );

    $c->redirect_to('/');
};

Thank you!

On 3/9/20 9:02 PM, Stefan Adams wrote:
Would Mojo::IOLoop->subprocess 
 
work for you?  Where the example shows sleep 5, put your system call 
to gvim?  Not sure if that's a good solution if gvim is a long-running 
process, tho.  Also, try it with `perl script daemon` as opposed to 
using `morbo`, maybe?  Or try the systemd setup for hypnotoad 
.  
Is there any chance that Minion 
 can help you here?  Minion is 
designed to handle long-running processes.


On Mon, Mar 9, 2020 at 8:24 PM Mike Lieman > wrote:


I don't think you want to use Daemon::Control.   How about a nice,
simple fork()?

On Mon, Mar 9, 2020 at 8:46 PM Matthew Pressly
mailto:matthew.pres...@gmail.com>> wrote:

From a mojolicious web app, I need to be able to launch gvim
by clicking a link or button to edit a particular file.

Currently, I have this in the app:

get '/edit' => sub {
my $c = shift;
my $result = `/usr/bin/gvim $filename 2>&1`;
$c->redirect_to('/');
};

Sometimes it works, but other times, gvim runs twice when the
link is clicked and more frequently, gvim runs but hangs up in
the background, after which I end up killing the gvim process
and killing and restarting the web app to get it back to working.

Is there a way to launch gvim (or other interactive programs)
more reliably?

I'm using the following for a start script:

#!/usr/bin/perl
use warnings;
use strict;
use Daemon::Control;
exit Daemon::Control->new(
    name     => "My Application",
lsb_start   => '$syslog $remote_fs',
lsb_stop    => '$syslog',
lsb_sdesc   => 'My App',
lsb_desc    => 'Controls the time tracker service.',
    #path       => '/home/symkat/etc/init.d/program',
program     => '/usr/bin/morbo',
program_args => [ '/path/to/mojolicious/app.pl
' ],
pid_file    => '/tmp/myapp.pid',
stderr_file => '/var/log/myapp/myapp.log',
stdout_file => '/var/log/myapp/myapp.log',

    user     => 'myuser',
    group       => 'myuser',
    fork     => 2,
)->run;


Thank you,

--
Matthew

-- 
You received this message because you are subscribed to the

Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to mojolicious+unsubscr...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/mojolicious/8930b24b-4e37-4b56-82ed-fad82031fe44%40googlegroups.com

.

-- 
You received this message because you are subscribed to the Google

Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to mojolicious+unsubscr...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/mojolicious/CAG2_C8CwMLwBXwVDdEicwpMYX1fvc3MHSo_CML_4Q7i%3DEHhwgg%40mail.gmail.com

.

--
You received this message because you are subscribed to the Google 
Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to mojolicious+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/CACyQ%2BFTkKXBF2xyCH2MZpywMEiqW1mxK9FdpfK0DGapR%2B26pbw%40mail.gmail.com 

Re: [Mojolicious] How to launch gvim reliably within a mojo app?

2020-03-09 Thread Stefan Adams
Would Mojo::IOLoop->subprocess

work for you?  Where the example shows sleep 5, put your system call to
gvim?  Not sure if that's a good solution if gvim is a long-running
process, tho.  Also, try it with `perl script daemon` as opposed to using
`morbo`, maybe?  Or try the systemd setup for hypnotoad
.
Is there any chance that Minion 
can help you here?  Minion is designed to handle long-running processes.

On Mon, Mar 9, 2020 at 8:24 PM Mike Lieman  wrote:

> I don't think you want to use Daemon::Control.   How about a nice, simple
> fork()?
>
> On Mon, Mar 9, 2020 at 8:46 PM Matthew Pressly 
> wrote:
>
>> From a mojolicious web app, I need to be able to launch gvim by clicking
>> a link or button to edit a particular file.
>>
>> Currently, I have this in the app:
>>
>> get '/edit' => sub {
>> my $c = shift;
>> my $result = `/usr/bin/gvim $filename 2>&1`;
>> $c->redirect_to('/');
>> };
>>
>> Sometimes it works, but other times, gvim runs twice when the link is
>> clicked and more frequently, gvim runs but hangs up in the background,
>> after which I end up killing the gvim process and killing and restarting
>> the web app to get it back to working.
>>
>> Is there a way to launch gvim (or other interactive programs) more
>> reliably?
>>
>> I'm using the following for a start script:
>>
>> #!/usr/bin/perl
>> use warnings;
>> use strict;
>> use Daemon::Control;
>>
>> exit Daemon::Control->new(
>> name=> "My Application",
>> lsb_start   => '$syslog $remote_fs',
>> lsb_stop=> '$syslog',
>> lsb_sdesc   => 'My App',
>> lsb_desc=> 'Controls the time tracker service.',
>> #path=> '/home/symkat/etc/init.d/program',
>>
>> program => '/usr/bin/morbo',
>> program_args => [ '/path/to/mojolicious/app.pl' ],
>>
>> pid_file=> '/tmp/myapp.pid',
>> stderr_file => '/var/log/myapp/myapp.log',
>> stdout_file => '/var/log/myapp/myapp.log',
>>
>> user=> 'myuser',
>> group=> 'myuser',
>>
>> fork=> 2,
>>
>> )->run;
>>
>>
>> Thank you,
>>
>> --
>> Matthew
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to mojolicious+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/mojolicious/8930b24b-4e37-4b56-82ed-fad82031fe44%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mojolicious+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mojolicious/CAG2_C8CwMLwBXwVDdEicwpMYX1fvc3MHSo_CML_4Q7i%3DEHhwgg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/CACyQ%2BFTkKXBF2xyCH2MZpywMEiqW1mxK9FdpfK0DGapR%2B26pbw%40mail.gmail.com.


[Mojolicious] How to launch gvim reliably within a mojo app?

2020-03-09 Thread Matthew Pressly
>From a mojolicious web app, I need to be able to launch gvim by clicking a 
link or button to edit a particular file.

Currently, I have this in the app:

get '/edit' => sub {
my $c = shift;
my $result = `/usr/bin/gvim $filename 2>&1`;
$c->redirect_to('/');
};

Sometimes it works, but other times, gvim runs twice when the link is 
clicked and more frequently, gvim runs but hangs up in the background, 
after which I end up killing the gvim process and killing and restarting 
the web app to get it back to working.

Is there a way to launch gvim (or other interactive programs) more 
reliably? 

I'm using the following for a start script:

#!/usr/bin/perl
use warnings;
use strict;
use Daemon::Control;
 
exit Daemon::Control->new(
name=> "My Application",
lsb_start   => '$syslog $remote_fs',
lsb_stop=> '$syslog',
lsb_sdesc   => 'My App',
lsb_desc=> 'Controls the time tracker service.',
#path=> '/home/symkat/etc/init.d/program',
 
program => '/usr/bin/morbo',
program_args => [ '/path/to/mojolicious/app.pl' ],
 
pid_file=> '/tmp/myapp.pid',
stderr_file => '/var/log/myapp/myapp.log',
stdout_file => '/var/log/myapp/myapp.log',

user=> 'myuser',
group=> 'myuser',
 
fork=> 2,
 
)->run;


Thank you,

--
Matthew 

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/8930b24b-4e37-4b56-82ed-fad82031fe44%40googlegroups.com.