Up and Running

Raze for days

Welcome to Raze! In this doc we will start with an empty project and get a simple server running on your local machine. It is assumed that you already have Crystal installed.

Creating an New Crystal Project

Run the following to create a scaffold for a new Crystal project, replacing app_name without your app name:

$ crystal init app app_name

Installing Raze

Go into you app's directory, and add the following to your shard.yml file:

    github: samueleaton/raze

With your shard.yml updated, install your dependencies:

$ shards install

Adding Your First Route

In the entry point to your app at src/app_name.cr, replace everything with the following:

require "raze"

get "/" do
  "yee, boi"


Running Your Server

With our route in place, let's compile and run our server using the following commands:

$ crystal build src/app_name.cr
$ ./app_name

Now visit http://localhost:7777 in your browser and you should see yee, boi.

Watching Files and Rebuilding on Every Change

This is all well and good, but every time we make a change to our code we need to manually restart our server. There is a tool called Sentry that makes it really easy to watch your file with no configuration. Since it is a dev dependency and not an app dependency, you don't need to add it to your shard.yml, so use the following command to install Sentry in your project:

$ curl -fsSLo- https://raw.githubusercontent.com/samueleaton/sentry/master/install.rb | ruby

Now just run ./sentry and sentry will compile your code, run your app, and if you change any files, it will recompile and restart your app.