Héberger un serveur

Pré-requis

  • Python >= 3.6

  • PostgreSQL >= 10

En plus de cela, un service de stockage de type objet est nécessaire afin de stocker les blocs de données chiffrés. À cette fin, Amazon S3 et OpenStack Swift sont tous deux supportés.

Hébergement

La communication entre client et serveur est effectuée via des Websocket. Ce protocole fournit une communication bidirectionnelle (nécessaire afin que le serveur puisse notifier le client des changements) tout en s’appuyant sur des standards du web.

Le serveur Parsec respecte la philosophie des applications à 12 facteurs. De ce fait une instance du serveur ne contient pas d’état et peut être remplacée à tout moment, ce qui la rend idéale pour un hébergement sur du PAAS ou bien au sein d’une architecture à base de conteneurs.

Au final, d’un point de vue hébergement, le serveur Parsec est similaire à une application web classique.

Installation

$ python -m venv venv
$ . ./venv/bin/activate
$ pip install parsec-cloud[backend]

Démarrage

Utiliser la commande parsec backend run pour démarrer le server Parsec, par exemple:

$ parsec backend run --port $PORT --host 0.0.0.0 --db postgresql://<...> --blockstore s3:<...> --administration-token <token>

Paramètres

Note

Des paramètres supplémentaires peuvent être spécifiés via la variable d’environnement PARSEC_CMD_ARGS. Tous les paramètres pouvant être passés via la ligne de commande sont utilisables et les variables d’environnement seront développées. Par exemple:

$ DB_URL=postgres:///parsec PARSEC_CMD_ARGS='--db=$DB_URL --host=0.0.0.0' parsec backend run

Host

  • --host <host>, -H <host>

  • Environ: PARSEC_HOST

  • Défaut: 127.0.0.1

Host sur lequel écouter.

Port

  • --port <port>, -P <port>

  • Environ: PARSEC_PORT

  • Défaut: 6777

Port sur lequel écouter.

Database URL

  • --db <url>

  • Environ: PARSEC_DB

Configuration de la base de données

Variables autorisées:

  • MOCKED: Simulé en mémoire

  • postgresql://<...>: Utilise une base PostgreSQL

Avertissement

MOCKED est disponible uniquement à des fins de développement et de test, il ne faut pas l’utiliser en production.

Connexion à la Base de données

  • --db-min-connections <int>

  • Environ: PARSEC_DB_MIN_CONNECTIONS

  • Défaut: 5

Nombre minimal de connexions à la base de données PostgreSQL.

  • --db-max-connections <int>

  • Environ: PARSEC_DB_MAX_CONNECTIONS

  • Défaut: 7

Nombre maximum de connexions à la base de données PostgreSQL.

URL de stockage des blocs

  • --blockstore <url>, -b <url>

  • Environ: PARSEC_BLOCKSTORE

Configuration du stockage des blocs

Variables autorisées:

  • MOCKED: Simulé en mémoire

  • POSTGRESQL: Utilise la base de données définie via le paramètre --db

  • s3:[<endpoint_url>]:<region>:<bucket>:<key>:<secret>: Use Amazon S3 storage

  • swift:<auth_url>:<tenant>:<container>:<user>:<password>: Use OpenStack SWIFT storage

Note endpoint_url/auth_url are considered as https by default (e.g. s3:foo.com:[…] -> https://foo.com). Escaping must be used to provide a custom scheme (e.g. s3:http\://foo.com:[…]).

En plus de ça, plusieurs configurations de blockstore peuvent être fournies pour former une grappe RAID0/1/5.

Chaque configuration doit être passée sous la forme``<raid_type>:<node>:<config>`` avec <raid_type> RAID0/RAID1/RAID5, <node> un nombre et <config> la configuration de type MOCKED/POSTGRESQL/S3/SWIFT.

Par exemple, pour configurer un RAID0 avec deux nœuds:

$ parsec backend run -b RAID0:0:MOCKED -b RAID0:1:POSTGRESQL [...]

Avertissement

MOCKED et POSTGRESQL sont disponibles uniquement à des fins de développement et de test, il ne faut pas les utiliser en production.

Jeton d’administration

  • --administration-token <token>

  • Environ: PARSEC_ADMINISTRATION_TOKEN

Jeton secret pour accéder à l’api d’administration.

SSL

  • --ssl-keyfile <file>

  • Environ: PARSEC_SSL_KEYFILE

Fichier de clé SSL

  • --ssl-certfile <file>

  • Environ: PARSEC_SSL_CERTFILE

Fichier de certificat SSL

Logs

  • --log-level <level>, -l <level>

  • Environ: PARSEC_LOG_LEVEL

  • Défaut: WARNING

Granularité des logs d’erreurs.

Doit être DEBUG, INFO, WARNING, ERROR ou CRITICAL.

  • --log-format <format>, -f <format>

  • Environ: PARSEC_LOG_FORMAT

  • Défaut: CONSOLE

Format de log utilisé. Doit être CONSOLE ou JSON.

  • --log-file <file>, -o <file>

  • Environ: PARSEC_LOG_FILE

  • Défaut: log dans stderr

Le fichier de log dans lequel écrire.

Email

  • --backend-addr

  • Environ: PARSEC_BACKEND_ADDR

URL to reach this server (typically used in invitation emails).

  • --email-host

  • Environ: PARSEC_EMAIL_HOST

The host to use for sending email.

  • --email-port

  • Environ: PARSEC_EMAIL_PORT

  • Default: 25

Port to use for the SMTP server defined in EMAIL_HOST.

  • --email-host-user

  • Environ: PARSEC_EMAIL_HOST_USER

Username to use for the SMTP server defined in EMAIL_HOST.

  • --email-host-password

  • Environ: PARSEC_EMAIL_HOST_PASSWORD

Password to use for the SMTP server defined in EMAIL_HOST. This setting is used in conjunction with EMAIL_HOST_USER when authenticating to the SMTP server.

  • --email-use-ssl

  • Environ: PARSEC_EMAIL_USE_SSL

Whether to use a TLS (secure) connection when talking to the SMTP server. This is used for explicit TLS connections, generally on port 587.

  • --email-use-tls

  • Environ: PARSEC_EMAIL_USE_TLS

Whether to use an implicit TLS (secure) connection when talking to the SMTP server. In most email documentation this type of TLS connection is referred to as SSL. It is generally used on port 465. Note that --email-use-tls/--email-use-ssl are mutually exclusive, so only set one of those settings to True.

  • --email-language

  • Environ: PARSEC_EMAIL_LANGUAGE

  • Default: en

Language used in email (Allowed values: en or fr).

Webhooks

  • --spontaneous-organization-bootstrap

  • Environ: PARSEC_SPONTANEOUS_ORGANIZATION_BOOTSTRAP

Allow organization bootstrap without prior creation.

Without this flag, an organization must be created by administration (see parsec core create_organization command) before bootstrap can occur.

With this flag, the server allows anybody to bootstrap an organanization by providing an empty bootstrap token given 1) the organization is not boostrapped yet and 2) the organization hasn’t been created by administration (which would act as a reservation and change the bootstrap token)

  • --organization-bootstrap-webhook

  • Environ: PARSEC_ORGANIZATION_BOOTSTRAP_WEBHOOK

URL to notify 3rd party service that a new organization has been bootstrapped.

Each time an organization is bootstrapped, an HTTP POST will be send to the URL with an application/json body with the following fields: organization_id, device_id, device_label (can be null), human_email (can be null), human_label (can be null).

Example:

{
  "organization_id": "MyOrg",
  "device_id": "123@abc",
  "device_label": "laptop",
  "human_email": "j.doe@example.com",
  "human_label": "John Doe"
}

Sentry

  • --sentry-url <url>

  • Environ: PARSEC_SENTRY_URL

URL de Sentry utilisé pour la télémétrie.

Débogage

  • --debug

  • Environ: PARSEC_DEBUG

Active les informations de débogage.

  • --dev

Équivalent à --debug --db=MOCKED --blockstore=MOCKED --administration-token=s3cr3t.