Archive for category heroku

Where to store custom templates in Xcode 4.3 ?


Since Xcode 4.3 onwards is a packaged application, you won’t be able to go to /Library/Developer/Xcode folder anymore.

Instead use the path:

/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/

to save any custom project template you want to store.

I spent some time investigating this as i was following the iOS heroku tutorial and it still refers to the old location.

https://devcenter.heroku.com/articles/ios-core-data-buildpack-app

,

Leave a comment

Installing Heroku CLI and Git …in 10 minutes!


If you are planning on playing with heroku, this post will help you get started in setting up your local machine with heroku CLI (command line interface) and Git (open source cloud based version control system).

Note that this post is a simplified and more detailed version of heroku quickstart article available at :

http://devcenter.heroku.com/articles/quickstart

Update — If you are using Mac OSX, you might want to just download the Heroku Toolbelt (http://toolbelt.heroku.com) The toolbelt (heroku CLI & Git ) will provide you everything you need to get started using Heroku!

Steps

1. Download Git for your OS and sign up for free Git account http://git-scm.com/download

2. A Heroku user account. Signup is free and instant.

3. Since heroku CLI is a ruby gem, in order to install it, you will need to install ruby locally on your machine.Installing the latest Ruby version with RVM is simply done by typing :

rvm install 1.9.3.

Note that if you do not have rvm installed, you can install it on mac/linux by:

$ bash curl -s https://rvm.beginrescueend.com/install/rvm.

You might need to prefix the    command using sudo ($ sudo curl -s https://rvm.beginrescueend.com/install/rvm)

4. Ensure that you have ruby installed by typing ruby –version

5. Using command line install heroku by typing:

$gem install heroku

Note that this will prompt you for your heroku credentials (which you used at step 2). After this step is finished your email address and API token will be saved to ~/.heroku/credentials

Also note that you might want to prefix the command with sudo (sudo gem install heroku) to make the command write the gem to the destination directories. If this still fails, try running:

$sudo gem install addressable

and then execute $sudo gem install heroku

6. It’s generally a good idea to add your public key immediately after installing the heroku gem so that you can use git to push or clone Heroku app repositories:

$heroku keys:add

sample output:

Enter your heroku crendentials:

Email: ssharaf@salesforce.com

password:******

Uploading ssh public key /Users/ssharaf/.ssh/id_rsa.pub.

7. At this point, you should be ready to start playing with the coolest PAAS (platform as a service) aka heroku!

Note that for application development you might want to install maven and OpenJDK v6 (for Java)

, , , , ,

Leave a comment

Create a simple Java Web App using Maven and Deploy to Heroku


This blog post will feature on creating a simple web application with a Maven Archetype plugin. The web application will:

  • Run in an embedded web application server (Jetty Server)
  • Have some dependencies added
  • Contain a simple servlet
  •  Generate a WAR file for deploying on heroku

1. Using Maven archetype:generate to create a web app which has an embedded Jetty Server (jetty-archetype-assembler) and a java class which starts the Jetty Server.

mvn archetype:generate -DarchetypeGroupId=org.mortbay.jetty.archetype -DarchetypeArtifactId=jetty-archetype-assembler -DarchetypeVersion=7.5.1.v20110908 -DgroupId=com.heroku.webapp -DartifactId=heroku1
thanks to John Simone & heroku team for working with Jetty team in creating this jetty-archetype-assembler!

2. This will generate a Java web project with standard web application structure. Inspect the pom.xml file and note that it has a maven app assembler plugin which will generate a script that sets up the required class path and runs the web application.

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<assembleDirectory>target</assembleDirectory>
<generateRepository>false</generateRepository>
<programs>
<program>
<mainClass>com.heroku.webapp.Main</mainClass>
<name>webapp</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>

Important —

Use your favorite editor and delete this line from the pom.xml file:

<generateRepository>false</generateRepository>

This is necessary because this archetype relies on the local maven repository being present at runtime, which is not the case once the app is deployed on heroku.

3. Compile the project using mvn compile.

mvn compile
[INFO] Scanning for projects…
[INFO]
[INFO] ————————————————————————
[INFO] Building heroku1 1.0-SNAPSHOT
[INFO] ————————————————————————
[INFO]
[INFO] — maven-resources-plugin:2.4.3:resources (default-resources) @ heroku1 —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] — maven-compiler-plugin:2.3.2:compile (default-compile) @ heroku1 —
[INFO] Compiling 1 source file to /Users/ssharaf/heroku/heroku1/target/classes
[INFO] ————————————————————————
[INFO] BUILD SUCCESS
[INFO] ————————————————————————
[INFO] Total time: 2.079s
[INFO] Finished at: Thu Nov 17 20:40:08 PST 2011
[INFO] Final Memory: 8M/81M
[INFO] ————————————————————————

 

4. Now we can package it using mvn package:

mvn package

Output —

[INFO] Scanning for projects…
[INFO]
[INFO] ————————————————————————
[INFO] Building heroku1 1.0-SNAPSHOT
[INFO] ————————————————————————
[INFO]
[INFO] — maven-resources-plugin:2.4.3:resources (default-resources) @ heroku1 —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] — maven-compiler-plugin:2.3.2:compile (default-compile) @ heroku1 —
[INFO] Nothing to compile – all classes are up to date
[INFO]
[INFO] — maven-resources-plugin:2.4.3:testResources (default-testResources) @ heroku1 —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/ssharaf/heroku/heroku1/src/test/resources
[INFO]
[INFO] — maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ heroku1 —
[INFO] Nothing to compile – all classes are up to date
[INFO]
[INFO] — maven-surefire-plugin:2.7.2:test (default-test) @ heroku1 —
[INFO] No tests to run.
[INFO] Surefire report directory: /Users/ssharaf/heroku/heroku1/target/surefire-reports

——————————————————-
T E S T S
——————————————————-
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] — maven-jar-plugin:2.3.1:jar (default-jar) @ heroku1 —
[INFO] Building jar: /Users/ssharaf/heroku/heroku1/target/heroku1-1.0-SNAPSHOT.jar
[INFO]
[INFO] — appassembler-maven-plugin:1.1.1:assemble (default) @ heroku1 —
[INFO] ————————————————————————
[INFO] BUILD SUCCESS
[INFO] ————————————————————————
[INFO] Total time: 2.496s
[INFO] Finished at: Thu Nov 17 20:41:15 PST 2011
[INFO] Final Memory: 5M/81M
[INFO] ————————————————————————

 

5. Next we create a Procfile which will define the process we want to run i.e. our main web app

I use VI editor on MAC.

e.g. vi Procfile

web:sh target/bin/webapp

 

6. Initialize the Git Repository by typing:

git init

now add the files using:

git add .

now commit the files to the repository using:

git commit -m “added heroku1 to the heroku cloud”

7. Now we are ready to create the Cedar Stack on heroku

$heroku create -s cedar

this will provision an application with some random name like cold-summer-876. Also it will configure git repository on heroku.

You can rename this to your app by using the heroku rename command.

e.g. $heroku rename heroku1

8. Lastly push the local git repository to heroku.

git push heroku master

This will take the whole git repository and upload it to heroku. Heroku recognizes it as java application using POM file and will use the dependencies defined to download appropriate artifacts. It will create a slug, which is basically a run time application instance. This slug gets replicated to a new dyno when we scale the app.

9. Now we can visit the app by using the command:

$heroku open

10. Some simple management commands to manage the app:

a. $heroku ps (shows the running processes)

b. $heroku log -t (will tail the logs)

c. $heroku scale web=2 (scale the web processes to 2)

d. $heroku releases (will show the last 2 releases)

Rel Change By When
—- ———————- ———- ———-
v33 Deploy d075337 ssharaf@salesforce.. 12 minutes ago
v32 Deploy 973f6e4 ssharaf@salesforce.. 16 minutes ago

Note that the content in the blog post was inspired by the tutorials on github by James Ward.

 

, , ,

Leave a comment