# ElixirNote Server

## TOC

* [Introduction](#introduction)
* [Who's this for?](#whos-this-for)
* [User](#user)
  * [Installation](#installation)
  * [Configurate the Elixir Server](#configurate-the-elixir-server)
  * [Launching a bare Elixir Server](#launching-a-bare-elixir-server)
* [Operators](#operators)
  * [Managing multiple extensions](#managing-multiple-extensions)
  * [Configuring Extensions](#configuring-extensions)
  * [Migrating from Notebook Server](#migrating-from-notebook-server)
  * [Running a public Elixir Server](#running-a-public-elixir-server)
  * [Security in the Elixir Server](#security-in-the-elixir-server)
  * [Configuring Logging](#configuring-logging)
* [Developers](#developers)
  * [Architecture Diagrams](#architecture-diagrams)
  * [Depending on Elixir Server](#depending-on-elixir-server)
  * [The REST API](#the-rest-api)
  * [Server Extensions](#server-extensions)
  * [File save hooks](#file-save-hooks)
  * [Content API](#content-api)
  * [WebSocket kernel wire protocols](#websocket-kernel-wire-protocols)
* [FAQ](#faq)

## Introduction

Elixr Server is the backend -- the core services, APIs, and REST endpoints -- to Elixir web applications.

{% hint style="info" %}
Elixir Server is a replacement for the Tornado Web Server in Notebook. Elixir web applications should move to use Elixir Server.
{% endhint %}

## Who's this for?

The Elixir Server is a highly technical piece of the Elixir Stack, so we've separated documents to help specific personas:

1. Users: people using Elixir web applications.
2. Operators: people deploying or serving Elixir web applications to others.
3. Developers: people writing Elixir Server extensions and web applications.

If you find gaps in the documents, please open an issue (or better, a pull request) on the Elixir Server [GitHub repo](https://github.com/ElixirNote/elixirserver).

## User

### Installation

To install the latest release locally, make sure you have [pip installed](https://pip.readthedocs.io/en/stable/installing/) and run:

```bash
pip install elixir-server
```

### Configurate the Elixir Server

#### Using an Elixir config file

By default, Elixir Server looks for server-specific configuration in a **`elixir_server_config`** file located on a Elixir path. To list the paths where Elixir Server will look, run:

```
elixir --paths

config:
    /Users/username/.elixir
    /usr/local/etc/elixir
    /etc/elixir
data:
    /Users/username/Library/elixir
    /usr/local/share/elixir
    /usr/share/elixir
runtime:
    /Users/username/Library/elixir/runtime
```

In Python files, these traits will have the prefix **`c.ServerApp`**. For example, your configuration file could look like this:

```bash
# Inside a elixir_server_config.py file.
c.ServerApp.port = 9999
```

#### Using the CLI

Alternatively, you can configure Elixir Server when launching from the command line using CLI args. Prefix each argument with --ServerApp like so:

```
elixir-server --ServerApp.port=9999
```

### Launching a bare Elixir Server

Most of the time, you won't need to start the Elixir Server directly. Elixir web applications come with their own entry points that start a server automatically.

Sometimes, though, it can be useful to start Elixir Server directly when you want to run multiple Elixir web applications at the same time, you can simple run the following:

```bash
elixir-server
[I 2022-12-21 10:11:21.746 ServerApp] Serving notebooks from local directory: /Users/admin/Git/Public/elixirnote
[I 2022-12-21 10:11:21.746 ServerApp] Elixir Server 2.1.0.dev204 is running at:
[I 2022-12-21 10:11:21.746 ServerApp] http://localhost:8888/?token=7649afb6db8dc2f7a56b5db110c025836aac21e78b30f3fe
[I 2022-12-21 10:11:21.746 ServerApp]  or http://127.0.0.1:8888/?token=7649afb6db8dc2f7a56b5db110c025836aac21e78b30f3fe
[I 2022-12-21 10:11:21.746 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
...
```

## Operators

### Managing multiple extensions

### Configuring Extensions

### Migrating from Notebook Server

### Running a public Elixir Server

### Security in the Elixir Server

### Configuring Logging

## Developers

### Architecture Diagrams

### Depending on Elixir Server

### The REST API

### Server Extensions

### File save hooks

### Content API

### WebSocket kernel wire protocols

## FAQ
