Skip to content

Commit d7f7a18

Browse files
authored
Merge pull request #5 from jakobbuis/patch-2
Add basic postgresql installation guidelines to database.md
2 parents 4d266eb + b219ddd commit d7f7a18

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

docs/database.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,57 @@ engines
1010
- Microsoft SQL Server
1111
- Oracle
1212

13-
See [SQLAlchemy's documentation](https://docs.sqlalchemy.org/en/20/core/engines.html) for more details.
13+
See [SQLAlchemy's documentation](https://docs.sqlalchemy.org/en/20/core/engines.html) for more details.
14+
15+
## PostgreSQL
16+
***
17+
18+
OpenTAKServer can be configured to use PostgreSQL as its database backend.
19+
20+
### Prerequisites
21+
22+
Before configuring OpenTAKServer to run on PostgreSQL, ensure you have:
23+
- The database CA certificate (if an SSL connection is desired or required)
24+
- Access to your PostgreSQL database with a typical database client
25+
- Database connection details (hostname, port, username, password)
26+
27+
### Installation
28+
29+
Install the required PostgreSQL adapter in OpenTAKServer:
30+
31+
```shell
32+
sudo apt-get install libpq-dev
33+
cd ~/.opentakserver_venv
34+
bin/pip install psycopg2
35+
```
36+
If `ssl_mode=required` is on, download the database CA certificate from your provider and place it in the `~/ots` directory.
37+
38+
Modify the settings in `~/ots/config.yml` to include:
39+
40+
```yaml
41+
SQLALCHEMY_DATABASE_URI: postgresql://[user]:[password]@[hostname]:[port]/[database]?sslmode=require
42+
SQLALCHEMY_ENGINE_OPTIONS:
43+
pool_pre_ping: true
44+
connect_args:
45+
sslmode: require
46+
sslrootcert: database-ca.crt
47+
```
48+
49+
Replace `[user]`, `[password]`, `[hostname]`, `[port]`, and `[database]` with your actual database connection details. You can leave `SQLALCHEMY_ENGINE_OPTIONS` as is if the database does not use an SSL connection.
50+
51+
### Troubleshooting
52+
OpenTAKServer does not produce detailed error reports when something is wrong with the configuration file or database. It's easier to temporarily turn the service off and run the program directly for debugging.
53+
54+
To get detailed feedback about connection issues, run OpenTAKServer directly instead of as a service:
55+
56+
```shell
57+
sudo systemctl stop opentakserver.service
58+
~/.opentakserver_venv/bin/opentakserver
59+
```
60+
61+
If you encounter schema permission issues, ensure the database user owns the `public` schema. You may need to recreate it with the correct ownership.
62+
63+
Finally, stop the OTS process in the terminal (Ctrl+C) and restart the service:
64+
```shell
65+
sudo systemctl start opentakserver.service
66+
```

0 commit comments

Comments
 (0)