Last Updated: February 25, 2016
·
964
· hsestupin

Running Noir project on the AWS Beanstalk

First, you should create an application on the AWS Beanstalk with tomcat environment and give it the same name as your lein project called. If it's your first try to deploy applications on the AWS than you have to create new security group and add new user. You can make this here https://console.aws.amazon.com/iam/. Next you will be suggested to download your security credentials (do it anyway).

So the part related to AWS is completed. For deploying Noir application to AWS I advise you to use lein plugin https://github.com/weavejester/lein-beanstalk . It's the simplest way to deploy your project. Now follow several steps described in https://github.com/weavejester/lein-beanstalk#basic-configuration.

Look at this string:

:ring {:handler hello-world.core/handler}

It should be added to your project.clj for proper converting Noir defpage's to ring handlers. So don't forget to define this variable handler as follows (in such example the file should be called core.clj):

(ns hello-world
    (:require [noir.server :as server]))

(require '(hello-world.views welcome common))

(def handler (server/gen-handler {:mode :dev
                              :ns 'hello-world}))

And check out that deployment will not work correctly without loading all you Noir view namespaces at this file. Here it's done with the help of require function.

That's all. Now you can type

lein beanstalk deploy development

and check your app at the http://hello-world-dev.elasticbeanstalk.com