Setup BlackD

What is BlackD

BlackD is the server daemon which you may use from Black

Install

Note the quotes!

sudo pip3 install 'black[d]'

Usage

blackd --help
Usage: blackd [OPTIONS]

Options:
  --bind-host TEXT     Address to bind the server to.
  --bind-port INTEGER  Port to listen on
  --version            Show the version and exit.
  -h, --help           Show this message and exit.

Container setup and systemd setup

https://github.com/N0K0/blackd-server

podman run -d -p 45474:45474 --name blackd n0k0/blackd-server
podman generate systemd blackd --new --name > /tmp/blackd.service

sudo mv /tmp/blackd.service /etc/systemd/system/

podman stop blackd
podman rm blackd

sudo systemctl daemon-reload
sudo systemctl enable blackd
sudo systemctl start blackd

Systemd setup

Based on minimal systemd unit

/etc/systemd/system/black.service

[Unit]
Description=BlackD


[Install]
WantedBy=multi-user.target

[Service]
Type=simple
# simple    : starts the service immediately. It is expected that the main process of the service is defined in `ExecStart`
# foking    : considers the service started up once the process forks and the parent has exited.
# oneshot   : similar to `simple`, but it is expected that the process has to exit before systemd starts follow-up units (useful for scripts that do a single job and then exit). You may want to set `RemainAfterExit=yes` as well so that systemd still considers the service as active after the process has exited.
# dbus      : similar to `simple`, but considers the service started up when the main process gains a D-Bus name.
# notify    : similar to `simple`, but considers the service started up only after it sends a special signal to systemd.
# idle      : similar to `simple`, but the actual execution of the service binary is delayed until all jobs are finished.


ExecStart=/usr/local/bin/blackd
Restart=on-failure

# no            : Never
# on-success    : Only on clean exit
# on-failure    : Everything but clean exit
# on-abnormal   : Unclean signal, timeout, watchdog
# on-watchdog   : Only watchdog trigger
# on-abort      : Only Unclean exit signal
# always        : Always

RemainAfterExit=false