How to run a server in background with CircleCI?

Viewed 2090

I am using CircleCI with my Django project. I want to run a server (specifically python manage.py runserver) in the background for some specific selenium tests.

My config.yml is somewhat like

version: 2
jobs:
  build:
    docker:
      - image: circleci/python:3.6.1-browsers
      - image: selenium/standalone-chrome

    working_directory: ~/myproject

    steps:
      - checkout
      - run:
          name: install dependencies
          command: |
            python3 -m venv venv
            . venv/bin/activate
            pip install -r requirements.txt

      - run:
          name: run unit tests
          command: |
            . venv/bin/activate
            python manage.py test

      - run:
          name: run selenium tests
          command: |
            . venv/bin/activate
            python manage.py migrate
            python manage.py runserver 8000 
            python manage.py run_selenium_tests         

I could make it work by running selenium tests inside django LiveServerTestCase. But I want to run selenium tests independently, for that I need runserver to be running in the background. Right now circleci stops execution at python manage.py runserver and eventually timeouts. Any idea to do this?

3 Answers
Related