Default SourceLair server commands

SourceLair runs the most commonly used default server commands for each project type. The server command which is run for each project type can be found below:

Django

In Django projects SourceLair will attempt to run the Django dev server by default using the following command:

./manage.py runserver 0.0.0.0:8000

Node.js

In Node.js projects SourceLair will attempt to run the start script in your package.json file via Nodemon using the following command:

nodemon start

PHP

In PHP projects SourceLair will attempt to run Apache2 using the following command:

apache2ctl -DFOREGROUND

HTML

In HTML projects SourceLair will attempt to run BrowserSync using the following command:

browser-sync start --server /mnt/project/ --port 8000 --files="**" --no-ui

Python (Flask)

In Python (Flask) projects SourceLair will attempt to run your app server using the following command:

python server.py

Customizing the server command

If you’d like to run custom server commands, you can do so by creating a Procfile. A Procfile is a mechanism for declaring what commands are run by your project’s server on SourceLair. It follows the process model. You can use a Procfile to declare various process types, such as multiple types of workers, a singleton process like a clock, or a consumer of an API. If you’d just like to have a different server command from the default ones, all you have to do is create a Procfile with a single web directive. Below you can find some examples for each project type:

Example Procfiles

# Django example Procfile
web: ./manage.py devserver --custom-flag=true
# Node.js example Procfile
web: nodemon --ignore lib/ --ignore tests/
# PHP example Procfile
web: bin/cake server
# HTML example Procfile
web: browser-sync start --port 8000 --files="**" --no-ui --directory
# Flask example Procfile
web: gunicorn -b 0.0.0.0:5000 --reload myproject:app

Procfile priority

Procfiles are great, though you most probably need to have different Procfiles for production deployment and development. SourceLair follows the priority below for the Procfiles in your project:

  1. The one defined in the $SL_PROCFILE environment varilable (read how to configure your project’s environment here)
  2. Procfile.dev
  3. Procfile

By laveraging the priority shown above, you can define a Procfile.dev for your SourceLair needs, while keeping a production ready Procfile for your Heroku or Deis deployment. Also, if you like keeping custom naming, you can always define your own Procfile in the $SL_PROCFILE environment variable.

Exposed server port and Public URL

In SourceLair, with every project you get a Public URL - a publicly available domain name that will always point to your project. You can find you Public URL by opening your project’s settings, or clicking the eye-like icon in the sidebar.

The Public URL will work for the most commonly used port for each project type. You can find the ports below:

  • Django - 8000
  • Node.js - 3000
  • PHP - 8000
  • HTML - 8000
  • Python (Flask) - 5000

If you’d like to dynamically add the port in your application, you can also make use of the $PORT environment variable which will have the correct value at all cases.