Newer Older
69 lines | 2.053kb
add files
Yuki Kimoto authored on 2014-03-26
1
#!/usr/bin/env perl
2

            
3
use strict;
4
use warnings;
5

            
6
use FindBin;
7
BEGIN { unshift @INC, "$FindBin::Bin/../lib" }
8

            
9
use Getopt::Long qw(GetOptions :config no_auto_abbrev no_ignore_case);
10

            
11
GetOptions
12
  'h|help'     => \my $help,
13
  'l|listen=s' => \my @listen,
14
  'm|mode=s'   => sub { $ENV{MOJO_MODE} = $_[1] },
15
  'v|verbose'  => sub { $ENV{MORBO_VERBOSE} = 1 },
16
  'w|watch=s'  => \my @watch;
17

            
18
die <<EOF if $help || !(my $app = shift);
19
usage: $0 [OPTIONS] [APPLICATION]
20

            
21
  morbo script/myapp
22
  morbo myapp.pl
23
  morbo -m production -l https://*:443
24
  morbo -w /usr/local/lib -w public myapp.pl
25

            
26
These options are available:
27
  -h, --help                     Show this message.
28
  -l, --listen <location>        Set one or more locations you want to listen
29
                                 on, defaults to the value of MOJO_LISTEN or
30
                                 "http://*:3000".
31
  -m, --mode <name>              Operating mode for your application, defaults
32
                                 to the value of MOJO_MODE/PLACK_ENV or
33
                                 "development".
34
  -v, --verbose                  Print details about what files changed to
35
                                 STDOUT.
36
  -w, --watch <directory/file>   Set one or more directories and files to
37
                                 watch for changes, defaults to the
38
                                 application script as well as the "lib" and
39
                                 "templates" directories in the current
40
                                 working directory.
41
EOF
42

            
43
$ENV{MOJO_LISTEN} = join(',', @listen) if @listen;
44
require Mojo::Server::Morbo;
45
my $morbo = Mojo::Server::Morbo->new;
46
$morbo->watch(\@watch) if @watch;
47
$morbo->run($app);
48

            
49
=encoding utf8
50

            
51
=head1 NAME
52

            
53
morbo - Morbo HTTP and WebSocket development server
54

            
55
=head1 SYNOPSIS
56

            
57
  $ morbo --help
58
  $ morbo myapp.pl
59

            
60
=head1 DESCRIPTION
61

            
62
Start L<Mojolicious> and L<Mojolicious::Lite> applications with the
63
L<Mojo::Server::Morbo> web server.
64

            
65
=head1 SEE ALSO
66

            
67
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
68

            
69
=cut