Usually I'm releasing my Mojo apps as packages, e.g. *App::MojoApp*.
Also I'm creating a *mojoapp* CLI tool (like this 
<https://metacpan.org/source/JBERGER/Galileo-0.041/bin/galileo>) which does 
Mojolicious::Commands->start_app(App::MojoApp*)* for easy running app from 
any place.

Would like to implement a custom command 
<http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Adding-commands-to-Mojolicious>
 
which running my app on hypnotoad production server.
Since Mojo::Server::Hypnotoad 
<https://metacpan.org/pod/Mojo::Server::Hypnotoad> can't load application 
from class, as Mojolicious::Commands::start_app() 
<https://metacpan.org/pod/Mojolicious::Commands#start_app> do, I need to 
impement finding a path to main mojo app module by myself.

Now it looks like
package App::MojoApp::Command::hypno;

use Mojo::Base 'Mojolicious::Command';
use Mojo::Server::Hypnotoad;

has description => 'Run app on hypnotoad production server';
has usage       => "Usage: APPLICATION hypno";

sub run {
  my ($self, @args) = @_;
  my $p = __PACKAGE__;
  my @s = split(/::/, $p);
  $p = join('::', $s[0], $s[1]);
  $p =~ s/::/\//g;
  $p =~ s/$/.pm/;
  my $hypnotoad = Mojo::Server::Hypnotoad->new;
  $hypnotoad->run($INC{$p});
}

1;

Is there any way built-in method to get an installation location of main 
mojo module ?

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to