~yerinalexey/gobin

262a5abe55470e6c214e84491a2086b01ce01f28 — Alexey Yerin 5 months ago b91ecee
docs: better configuration section, rm systemd
3 files changed, 9 insertions(+), 52 deletions(-)

M README.md
D contrib/systemd/gobin.service
D contrib/systemd/gobin.service.d/environment.conf
M README.md => README.md +9 -27
@@ 23,16 23,20 @@ export DATABASE_URI=posgtresql://USER:PASSWORD@localhost/DB
- `DB` is your database name (make sure to run `create database` before running)

## Configuration
If you want to change port on which application is running, set `PORT`
environment variable (4000 is default).
Configuration is done via environment variables:

If your application is hosted not on localhost, you should change
`BASE_URL` environment variable to `http://` or `https://` + your domain
(e.g. `https://somesite.dev`)
- `PORT` - change port on which application is running (default: 4000)
- `BASE_URL` - base URL for permalinks, no trailing slash (default: `http://localhost:4000`)
- `TEMPLATE_ROOT` - where templates are located (default: `./templates`)
- `STATIC_ROOT` - where static files are located (default: `./static`)

Example:
```sh
export BASE_URL=https://somesite.dev
export PORT=80 # Note: you might need to run gobin as root

export TEMPLATE_ROOT=/usr/share/gobin/templates
export STATIC_ROOT=/usr/share/gobin/static
```

## Building


@@ 58,25 62,3 @@ If something goes wrong, you can apply migrations manually by running

It's also a good idea to run `gobin` binary as a system service. Make
sure to provide all environment variables.

## Using systemd
```sh
# Copy templates and static files
sudo mkdir -p /usr/share/gobin
sudo cp -r templates static /usr/share/gobin

# Add SystemD unit
sudo cp -r ./contrib/systemd/gobin.service ./contrib/systemd/gobin.service.d /etc/systemd/system

# Edit /etc/systemd/system/gobin.service.d/environment.conf to set environment variables

# Install gobin itself
sudo install ./gobin /usr/local/bin

# Reload units and start gobin
sudo systemctl daemon-reload
sudo systemctl start gobin
```

## Using OpenRC
TODO: Write the service and this doc

D contrib/systemd/gobin.service => contrib/systemd/gobin.service +0 -19
@@ 1,19 0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This unit runs gobin as a system service. It requires gobin to be
# available in your PATH (/usr/bin, /usr/local/bin, etc). To place it
# there use:
# sudo install ./gobin /usr/local/bin

[Unit]
Description=Simple self-hosted service for sharing text snippets
Requires=network.target

[Service]
Type=simple
ExecStart=gobin
Environment="TEMPLATE_ROOT=/usr/share/gobin/templates"
Environment="STATIC_ROOT=/usr/share/gobin/static"

[Install]
WantedBy=multi-user.target

D contrib/systemd/gobin.service.d/environment.conf => contrib/systemd/gobin.service.d/environment.conf +0 -6
@@ 1,6 0,0 @@
# This file is a template, edit to your own liking

[Service]
Environment="DATABASE_URI=posgtresql://andrew:super_secret_haha@localhost/pastebin"
Environment="BASE_URL=https://mywebsite.com"
Environment="PORT=80"