Skip to content

Commit

Permalink
[CveXplore-278] wip docs
Browse files Browse the repository at this point in the history
  • Loading branch information
P-T-I committed Apr 19, 2024
1 parent 1b6d721 commit 87afa3c
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CveXplore/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@

@click.group(invoke_without_command=True)
@click.option("-v", "--version", is_flag=True, help="Show the current version and exit")
@click.option("-w", "--where", is_flag=True, help="Show the path where CveXplore is installed")
@click.pass_context
def main(ctx, version):
def main(ctx, version, where):
ctx.obj = {"data_source": CveXplore()}
if version:
click.echo(ctx.obj["data_source"].version)
exit(0)
elif where:
click.echo(ctx.obj["data_source"].where())
exit(0)
if ctx.invoked_subcommand is None:
click.echo(main.get_help(ctx))

Expand Down
10 changes: 10 additions & 0 deletions CveXplore/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ def version(self) -> str:
"""
return self.__version

@staticmethod
def where() -> str:
"""
Request the path where CveXplore is installed
Returns:
Path where CveXplore is installed
"""
return os.path.dirname(__file__)

def get_single_store_entry(
self, entry_type: str, dict_filter: dict = None
) -> CveXploreObject | None:
Expand Down
17 changes: 17 additions & 0 deletions backend/.docker/cvexplore-backend.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=CveXplore Backend service
Requires=docker.service
After=docker.service

[Service]
Restart=always
WorkingDirectory=${HOME}/.cvexplore
# Shutdown container (if running) when unit is started
ExecStartPre=/usr/bin/docker-compose -f docker-compose.yml down
# Start container when unit is started
ExecStart=/usr/bin/docker-compose -f docker-compose.yml up
# Stop container when unit is stopped
ExecStop=/usr/bin/docker-compose -f docker-compose.yml down

[Install]
WantedBy=multi-user.target
48 changes: 48 additions & 0 deletions backend/.docker/docker-compose_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: '3.5'

services:

redis:
image: cvexplore-redis
hostname: redis
restart: always
volumes:
- redis_data:/data
ports:
- "127.0.0.1:6379:6379"

celery_daemon:
image: cvexplore-celery_daemon
depends_on:
- redis
env_file:
- ${HOME}/.cvexplore/.env
extra_hosts:
- "host.docker.internal:host-gateway"
deploy:
replicas: 2
restart: always
environment:
- PYTHONUNBUFFERED=TRUE
volumes:
- celery_data:/app/data

celery_beat:
image: cvexplore-celery_beat
depends_on:
- redis
env_file:
- ${HOME}/.cvexplore/.env
extra_hosts:
- "host.docker.internal:host-gateway"
restart: always
environment:
- PYTHONUNBUFFERED=TRUE
volumes:
- celery_data:/app/data

volumes:
celery_data:
driver: local
redis_data:
driver: local
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ services:
- redis
env_file:
- ${HOME}/.cvexplore/.env
extra_hosts:
- "host.docker.internal:host-gateway"
restart: always
environment:
- PYTHONUNBUFFERED=TRUE
Expand Down
9 changes: 9 additions & 0 deletions docs/backend/general.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
General
-------

The backend as referred to in this documentation consists of a celery daemon with a redis broker.
This will give CveXplore the possibility to easily create and maintain background tasks for for instance database
maintenance and re-processing of updated database entries.

The use of this backend is **optional** and CveXplore can function perfectly without one; the tasks it performs can well
be handled by another mechanism. It is, however, a nice addition to the functionalities CveXplore offers.

Task handling (CRUD actions en status updates) are handled via a separate class and can be controlled via package or
CLI commands.
18 changes: 16 additions & 2 deletions docs/backend/installation.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
Installation
------------

The backend assumes that the CveXplore package is installed; check the package :ref:`installation <index:installation>`
paragraph.
The backend assumes that the CveXplore package is installed **first**; check the package :ref:`installation <index:installation>`
paragraph.

Docker
######

Please ensure that you have docker and docker-compose installed before processing with the rest of this paragraph.



Systemd
#######

The backend tasks are powered by celery; please follow
`these instructions <https://docs.celeryq.dev/en/stable/userguide/daemonizing.html#usage-systemd>`_ if you prefer
to use systemd instead of a docker deployment
2 changes: 2 additions & 0 deletions docs/backend/settings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Settings
--------
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ Welcome to CveXplore's documentation!

/backend/general
/backend/installation
/backend/settings

0 comments on commit 87afa3c

Please sign in to comment.