Permalink
Browse files

Use Carton; add support for PSGI

  • Loading branch information...
1 parent 7ce412f commit 5c6bd6f147b11700fbef39a956eb5d5d33238244 @judofyr committed Feb 13, 2012
Showing with 39 additions and 33 deletions.
  1. +17 −18 README.md
  2. +15 −9 bin/compile
  3. +5 −4 bin/detect
  4. +2 −2 bin/release
View
@@ -3,7 +3,7 @@ Perloku
Deploy Perl applications in seconds.
-## Step 1
+## Step 1: App
Write an app:
@@ -32,7 +32,7 @@ Welcome to the Mojolicious real-time web framework!
</html>
```
-## Step 2
+## Step 2: Dependencies
Create a Makefile.PL with your dependencies:
@@ -52,31 +52,30 @@ WriteMakefile(
);
```
-## Step 3
-
-Create an executable file called Perloku which runs a server on the port
-given as an enviroment variable:
+Run Carton and generate a `carton.lock`:
```sh
-#!/bin/sh
-./app.pl daemon --listen http://*:$PORT
+carton install
+git add carton.lock
+git commit -m "Added carton.lock"
```
-Test that you can start the server:
+## Step 3: Server
-```sh
-chmod +x Perloku
-PORT=3000 ./Perloku
-```
+If you're using PSGI you can simply create an `app.psgi` and Perloku will
+automatically run the app using Starman.
-## Step 4
+If you're not using PSGI, you must create a
+[Procfile](http://devcenter.heroku.com/articles/procfile) that tells
+Heroku how to run your server:
+
+```
+web: ./app.pl daemon --listen http://*:$PORT
+```
-Deploy:
+## Step 4: Deploy
```sh
-git init
-git add .
-git commit -m "Initial version"
heroku create -s cedar --buildpack http://github.com/judofyr/perloku.git
git push heroku master
```
View
@@ -22,17 +22,23 @@ export PERL5LIB="$VENDORED_PERL/lib/$PERL_VERSION:$VENDORED_PERL/lib/site_perl/$
echo "Using Perl $PERL_VERSION" | indent
-if [ -f $BUILD_DIR/Makefile.PL ]; then
- echo "-----> Installing dependencies"
- VENDOR_DEPS="$BUILD_DIR/vendor/perl-deps"
- CACHE_DEPS="$CACHE_DIR/perl-deps"
- CPANM="perl -S $(which cpanm) -l $CACHE_DEPS"
+CPANM="perl -S cpanm --notest"
- mkdir -p "$CACHE_DIR"
- $CPANM --notest --installdeps $BUILD_DIR 2>&1 | indent
+echo "-----> Installing Carton"
+$CPANM carton
- cp -R "$CACHE_DEPS" "$VENDOR_DEPS"
+# Clear previous cache dir
+rm -rf "$CACHE_DIR/perl-deps"
+VENDOR_DEPS="$BUILD_DIR/local"
+CACHE_DEPS="$CACHE_DIR/local"
- echo "Dependencies installed" | indent
+if [ -f $BUILD_DIR/app.psgi ]; then
+ echo "-----> Installing Starman"
+ $CPANM -l $CACHE_DEPS Starman
fi
+echo "-----> Installing dependencies"
+perl -S carton install --path "$CACHE_DEPS" 2>&1 | indent
+cp -R "$CACHE_DEPS" "$VENDOR_DEPS"
+echo "Dependencies installed" | indent
+
View
@@ -1,9 +1,10 @@
#!/bin/sh
-if [ -x $1/Perloku ]; then
- echo "Perloku"
- exit 0
+[ -f $1/carton.lock ] || exit 1
+
+if [ -f $1/app.psgi ]; then
+ echo "PSGI"
else
- exit 1
+ echo "Perl"
fi
View
@@ -6,7 +6,7 @@ cat << EOF
---
config_vars:
PATH: /app/vendor/perl/bin:/usr/bin:/bin
- PERL5OPT: -Mlocal::lib=/app/vendor/perl-deps
+ PERL5OPT: -Mlocal::lib=/app/local
default_process_types:
- web: ./Perloku $PORT
+ web: perl -S starman --preload-app --port \$PORT
EOF

0 comments on commit 5c6bd6f

Please sign in to comment.