Skip to content

Commit

Permalink
Use Carton; add support for PSGI
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr committed Feb 13, 2012
1 parent 7ce412f commit 5c6bd6f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
35 changes: 17 additions & 18 deletions README.md
Expand Up @@ -3,7 +3,7 @@ Perloku

Deploy Perl applications in seconds.

## Step 1
## Step 1: App

Write an app:

Expand Down Expand Up @@ -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:
Expand All @@ -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
```
Expand Down
24 changes: 15 additions & 9 deletions bin/compile
Expand Up @@ -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

9 changes: 5 additions & 4 deletions bin/detect
@@ -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

4 changes: 2 additions & 2 deletions bin/release
Expand Up @@ -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.