Browse Source

Merge pull request #1019 from jberger/carton

Perl/Mojolicious: Add Carton to perl.sh and use
Hamilton Turner 11 years ago
parent
commit
8c71042cd0

+ 14 - 0
frameworks/Perl/mojolicious/README.md

@@ -11,6 +11,9 @@
 * JSON::XS
 * Hypnotoad provided by Mojolicious
 
+The included cpanfile shows the declared depenencies for the app.
+The included cpanfile.snapshot pins the deployment to the actual versions used during development (generated by carton).
+
 # Deployment
 
 Set production mode:
@@ -25,3 +28,14 @@ To stop again, simply run
 
     hypnotoad -s app.pl
 
+# Contact
+
+Joel Berger (jberger, core dev team member, author of this app) - github:jberger
+Sebastian Riedel (sri/kraih, project founder)- http://mojolicio.us/perldoc/Mojolicious#PROJECT-FOUNDER
+Core developer team - http://mojolicio.us/perldoc/Mojolicious#CORE-DEVELOPERS
+
+If considering changes from the above people, please consider them approved.
+Otherwise we would appreciate a heads up about implemenation changes.
+
+IRC: #mojo on irc.perl.org
+

+ 2 - 2
frameworks/Perl/mojolicious/app.pl

@@ -23,8 +23,8 @@ app->config->{hypnotoad}{workers} = app->config->{workers};
 
 helper mango   => sub { state $mango = Mango->new('mongodb://'. shift->config->{database_host}) };
 helper db      => sub { state $db = shift->mango->db('hello_world') };
-helper world   => sub { shift->db->collection('world') };
-helper fortune => sub { shift->db->collection('fortune') };
+helper world   => sub { state $world = shift->db->collection('world') };
+helper fortune => sub { state $fortune = shift->db->collection('fortune') };
 
 # JSON::XS renderer
 

+ 2 - 2
frameworks/Perl/mojolicious/cpanfile

@@ -1,5 +1,5 @@
-requires 'Mojolicious';
-requires 'Mango';
+requires 'Mojolicious', '>= 5.0';
+requires 'Mango', '>= 1.0';
 requires 'JSON::XS';
 requires 'EV';
 

+ 171 - 0
frameworks/Perl/mojolicious/cpanfile.snapshot

@@ -0,0 +1,171 @@
+# carton snapshot format: version 1.0
+DISTRIBUTIONS
+  EV-4.17
+    pathname: M/ML/MLEHMANN/EV-4.17.tar.gz
+    provides:
+      EV 4.17
+      EV::MakeMaker undef
+    requirements:
+      ExtUtils::MakeMaker 0
+      common::sense 0
+  JSON-XS-3.01
+    pathname: M/ML/MLEHMANN/JSON-XS-3.01.tar.gz
+    provides:
+      JSON::XS 3.01
+    requirements:
+      ExtUtils::MakeMaker 0
+      Types::Serialiser 0
+      common::sense 0
+  Mango-1.05
+    pathname: S/SR/SRI/Mango-1.05.tar.gz
+    provides:
+      Mango 1.05
+      Mango::BSON undef
+      Mango::BSON::Binary undef
+      Mango::BSON::Code undef
+      Mango::BSON::Document undef
+      Mango::BSON::ObjectID undef
+      Mango::BSON::Time undef
+      Mango::BSON::Timestamp undef
+      Mango::BSON::_MaxKey undef
+      Mango::BSON::_MinKey undef
+      Mango::Bulk undef
+      Mango::Collection undef
+      Mango::Cursor undef
+      Mango::Database undef
+      Mango::GridFS undef
+      Mango::GridFS::Reader undef
+      Mango::GridFS::Writer undef
+      Mango::Protocol undef
+    requirements:
+      ExtUtils::MakeMaker 0
+      Mojolicious 5.0
+  Mojolicious-5.28
+    pathname: S/SR/SRI/Mojolicious-5.28.tar.gz
+    provides:
+      Mojo undef
+      Mojo::Asset undef
+      Mojo::Asset::File undef
+      Mojo::Asset::Memory undef
+      Mojo::Base undef
+      Mojo::ByteStream undef
+      Mojo::Cache undef
+      Mojo::Collection undef
+      Mojo::Content undef
+      Mojo::Content::MultiPart undef
+      Mojo::Content::Single undef
+      Mojo::Cookie undef
+      Mojo::Cookie::Request undef
+      Mojo::Cookie::Response undef
+      Mojo::DOM undef
+      Mojo::DOM::CSS undef
+      Mojo::DOM::HTML undef
+      Mojo::Date undef
+      Mojo::EventEmitter undef
+      Mojo::Exception undef
+      Mojo::Headers undef
+      Mojo::HelloWorld undef
+      Mojo::Home undef
+      Mojo::IOLoop undef
+      Mojo::IOLoop::Client undef
+      Mojo::IOLoop::Delay undef
+      Mojo::IOLoop::Server undef
+      Mojo::IOLoop::Stream undef
+      Mojo::JSON undef
+      Mojo::JSON::Pointer undef
+      Mojo::JSON::_Bool undef
+      Mojo::Loader undef
+      Mojo::Log undef
+      Mojo::Message undef
+      Mojo::Message::Request undef
+      Mojo::Message::Response undef
+      Mojo::Parameters undef
+      Mojo::Path undef
+      Mojo::Reactor undef
+      Mojo::Reactor::EV undef
+      Mojo::Reactor::Poll undef
+      Mojo::Server undef
+      Mojo::Server::CGI undef
+      Mojo::Server::Daemon undef
+      Mojo::Server::Hypnotoad undef
+      Mojo::Server::Morbo undef
+      Mojo::Server::PSGI undef
+      Mojo::Server::PSGI::_IO undef
+      Mojo::Server::Prefork undef
+      Mojo::Template undef
+      Mojo::Transaction undef
+      Mojo::Transaction::HTTP undef
+      Mojo::Transaction::WebSocket undef
+      Mojo::URL undef
+      Mojo::Upload undef
+      Mojo::UserAgent undef
+      Mojo::UserAgent::CookieJar undef
+      Mojo::UserAgent::Proxy undef
+      Mojo::UserAgent::Server undef
+      Mojo::UserAgent::Transactor undef
+      Mojo::Util undef
+      Mojolicious 5.28
+      Mojolicious::Command undef
+      Mojolicious::Command::cgi undef
+      Mojolicious::Command::cpanify undef
+      Mojolicious::Command::daemon undef
+      Mojolicious::Command::eval undef
+      Mojolicious::Command::generate undef
+      Mojolicious::Command::generate::app undef
+      Mojolicious::Command::generate::lite_app undef
+      Mojolicious::Command::generate::makefile undef
+      Mojolicious::Command::generate::plugin 0.01
+      Mojolicious::Command::get undef
+      Mojolicious::Command::inflate undef
+      Mojolicious::Command::prefork undef
+      Mojolicious::Command::psgi undef
+      Mojolicious::Command::routes undef
+      Mojolicious::Command::test undef
+      Mojolicious::Command::version undef
+      Mojolicious::Commands undef
+      Mojolicious::Controller undef
+      Mojolicious::Lite undef
+      Mojolicious::Plugin undef
+      Mojolicious::Plugin::Charset undef
+      Mojolicious::Plugin::Config undef
+      Mojolicious::Plugin::Config::Sandbox undef
+      Mojolicious::Plugin::DefaultHelpers undef
+      Mojolicious::Plugin::EPLRenderer undef
+      Mojolicious::Plugin::EPRenderer undef
+      Mojolicious::Plugin::HeaderCondition undef
+      Mojolicious::Plugin::JSONConfig undef
+      Mojolicious::Plugin::Mount undef
+      Mojolicious::Plugin::PODRenderer undef
+      Mojolicious::Plugin::TagHelpers undef
+      Mojolicious::Plugins undef
+      Mojolicious::Renderer undef
+      Mojolicious::Routes undef
+      Mojolicious::Routes::Match undef
+      Mojolicious::Routes::Pattern undef
+      Mojolicious::Routes::Route undef
+      Mojolicious::Sessions undef
+      Mojolicious::Static undef
+      Mojolicious::Types undef
+      Mojolicious::Validator undef
+      Mojolicious::Validator::Validation undef
+      Test::Mojo undef
+      ojo undef
+    requirements:
+      ExtUtils::MakeMaker 0
+      Pod::Simple 3.09
+  Types-Serialiser-1.0
+    pathname: M/ML/MLEHMANN/Types-Serialiser-1.0.tar.gz
+    provides:
+      JSON::PP::Boolean 1.0
+      Types::Serialiser 1.0
+      Types::Serialiser::BooleanBase 1.0
+      Types::Serialiser::Error 1.0
+    requirements:
+      ExtUtils::MakeMaker 0
+      common::sense 0
+  common-sense-3.73
+    pathname: M/ML/MLEHMANN/common-sense-3.73.tar.gz
+    provides:
+      common::sense 3.73
+    requirements:
+      ExtUtils::MakeMaker 0

+ 1 - 1
frameworks/Perl/mojolicious/install.sh

@@ -2,5 +2,5 @@
 
 fw_depends perl
 
-cpanm --notest --no-man-page --installdeps $TROOT
+carton install --cpanfile $TROOT/cpanfile
 echo installed Mojolicious app dependencies

+ 3 - 5
frameworks/Perl/mojolicious/setup.py

@@ -1,27 +1,25 @@
 import subprocess
-import sys
 import json
 import os
-import getpass
 
 def start(args, logfile, errfile):
   conf = { 
     'database_host' : args.database_host,
     'workers'       : args.max_threads,
   }
-  with open('mojolicious/app.conf', 'w') as f:
+  with open(args.troot + '/app.conf', 'w') as f:
     f.write(json.dumps(conf))
 
   try:
     # os.environ["MOJO_MODE"] = "production"
-    subprocess.Popen("hypnotoad $TROOT/app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
+    subprocess.Popen("carton exec hypnotoad $TROOT/app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
     return 0
   except subprocess.CalledProcessError:
     return 1
 
 def stop(logfile, errfile):
   try:
-    subprocess.call("hypnotoad -s $TROOT/app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
+    subprocess.call("carton exec hypnotoad -s $TROOT/app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
     return 0
   except subprocess.CalledProcessError:
     return 1

+ 1 - 1
toolset/setup/linux/languages/perl.sh

@@ -11,4 +11,4 @@ fw_get http://cpanmin.us -O cpanminus.pl
 perl-5.18/bin/perl cpanminus.pl --notest --no-man-page App::cpanminus
 # Install only a bare-bones of Perl modules
 # Install others in the per-framework install script or cpanfile
-perl-5.18/bin/cpanm -f --notest --no-man-page JSON JSON::XS IO::Socket::IP IO::Socket::SSL
+perl-5.18/bin/cpanm -f --notest --no-man-page Carton JSON JSON::XS IO::Socket::IP IO::Socket::SSL