Running Sling

Before we start, make sure that you have:

Let’s go

1) Rename the Sling application jar: sling-app.jar

2) Create a new directory (henceforth known as SLING_HOME), copy sling-app.jar into that directory and then step into it.

3) Type the following to see what options are available to you:

java -jar sling-app.jar -h

and you should get back something like

usage: org.apache.sling.launcher.app.main.Main [ -l loglevel ] [ -f logfile ] [ -c slinghome ] [ -a address ] [ -p port ] [ -h ]
-l loglevel   the initial loglevel (0..4, FATAL, ERROR, WARN, INFO, DEBUG)
-f logfile    the log file, "-" for stdout (default logs/error.log)
-c slinghome  the sling context directory (default sling)
-a address    the interfact to bind to (use 0.0.0.0 for any) (not supported yet)
-p port       the port to listen to (default 8080)
-h              prints this usage message

Create a script to run this to save future typing and link to it from you somewhere on you command path so that you can run Sling from anywhere on your desktop (i’m a macosx command line user, sorry). I put the following script into a file called sling.sh:

SLING_HOME=/Users/clevegibbon/data/projects/day/apps/sling
java -jar $SLING_HOME/sling-app.jar -c $SLING_HOME/sling -f sling.log

And created a symbolic link to SLING_HOME/sling.sh from my $HOME/bin directory that’s on my command $PATH as follows:

ln -s /Users/clevegibbon/data/projects/day/apps/sling/sling.sh sling

Now, when I type sling from anywhere, it fires up sling, logs everything to SLING_HOME/sling.log and you get the following messages delivered to stdout, telling you that you can access sling on http://localhost:8080

2008-11-06 16:11:12.249::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2008-11-06 16:11:12.287::INFO:  jetty-6.1.x
2008-11-06 16:11:12.323::INFO:  Started SocketConnectorWrapper@0.0.0.0:8080

Stopping Sling

You can do this from the web console’s System Information tab (http://localhost:8080/system/console/vmstat). See the Stop button in the picture below, whack that to stop Sling. Alternatively, its a Ctrl-C from the command line.

Starting Over

If at any point you trash your Sling installation and/or you want to start afresh, this is just a simple matter of stopping sling, removing SLING_HOME/sling directory, because that’s where the JCR repository is and re-running sling.

Next Steps