Skip to content

Commit

Permalink
reorganize and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
agahkarakuzu committed Sep 4, 2024
1 parent 2605fce commit 3be9d4d
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 83 deletions.
12 changes: 0 additions & 12 deletions api/changes.md

This file was deleted.

4 changes: 2 additions & 2 deletions api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def load_yaml(file):
data = yaml.safe_load(file)
return data

common_config = load_yaml('common_config.yaml')
preview_config = load_yaml('preview_config.yaml')
common_config = load_yaml('config/common.yaml')
preview_config = load_yaml('config/preview.yaml')

# GLOBAL VARIABLES
BOOK_PATHS = f"{common_config['DATA_ROOT_PATH']}/{common_config['JB_ROOT_FOLDER']}/*/*/*/*.tar.gz"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions api/neurolibre_celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
# from myst_libre.rees import REES
# from myst_libre.builders import MystBuilder

preview_config = load_yaml('preview_config.yaml')
preprint_config = load_yaml('preprint_config.yaml')
common_config = load_yaml('common_config.yaml')
preview_config = load_yaml('config/preview.yaml')
preprint_config = load_yaml('config/preprint.yaml')
common_config = load_yaml('config/common.yaml')

config_keys = [
'DOI_PREFIX', 'DOI_SUFFIX', 'JOURNAL_NAME', 'PAPERS_PATH', 'BINDER_REGISTRY',
Expand Down
2 changes: 1 addition & 1 deletion api/neurolibre_common_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Document registration of the following endpoints must be performed by the app that
# imports this blueprint.

common_config = load_yaml('common_config.yaml')
common_config = load_yaml('config/common.yaml')
DATA_ROOT_PATH = common_config['DATA_ROOT_PATH']
JOURNAL_NAME = common_config['JOURNAL_NAME']

Expand Down
4 changes: 2 additions & 2 deletions api/neurolibre_preprint_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
app = flask.Flask(__name__)

# Load configurations from YAML files and update Flask app config
preprint_config = load_yaml('preprint_config.yaml')
common_config = load_yaml('common_config.yaml')
preprint_config = load_yaml('config/preprint.yaml')
common_config = load_yaml('config/common.yaml')
app.config.update(preprint_config)
app.config.update(common_config)

Expand Down
4 changes: 2 additions & 2 deletions api/neurolibre_preview_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
app = flask.Flask(__name__)

# Load and update app configuration from YAML files
preview_config = load_yaml('preview_config.yaml')
common_config = load_yaml('common_config.yaml')
preview_config = load_yaml('config/preview.yaml')
common_config = load_yaml('config/common.yaml')
app.config.update(preview_config)
app.config.update(common_config)

Expand Down
56 changes: 0 additions & 56 deletions api/old.py

This file was deleted.

4 changes: 2 additions & 2 deletions api/preprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

load_dotenv()

common_config = load_yaml('common_config.yaml')
preprint_config = load_yaml('preprint_config.yaml')
common_config = load_yaml('config/common.yaml')
preprint_config = load_yaml('config/preprint.yaml')

BINDER_REGISTRY = common_config['BINDER_REGISTRY']
DATA_ROOT_PATH = common_config['DATA_ROOT_PATH']
Expand Down
81 changes: 78 additions & 3 deletions systemd/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Prerequisites

Check that the `redis-server` service is (installed and) running:
* Check that the `redis-server` service is (installed and) running:

```bash
sudo systemctl status redis-server
Expand All @@ -16,6 +16,8 @@ sudo systemctl start redis-server

The redis server is expected to run on port 6379 (by celery).

* Check that a python virtual environment has been created and the dependencies (`<full-stack-server>/api/requirements.txt`) have been installed to that environment.

### Starting the Celery service

#### Copy over systemd and environment files
Expand All @@ -25,7 +27,7 @@ sudo cp <full-stack-server>/api/systemd/neurolibre-celery.service /etc/systemd/s
sudo cp <full-stack-server>/api/systemd/default/celery /etc/default/
```

Make sure that the `neurolibre-server` file has correct permissions after copying:
Make sure that the `celery` file has correct permissions after copying:

```bash
sudo chown ubuntu:ubuntu /etc/default/celery
Expand Down Expand Up @@ -89,4 +91,77 @@ To clear the cache, simply delete the `__pycache__` folder in the root directory

```bash
rm -rf <full-stack-server>/api/__pycache__
```
```

## Starting NeuroLibre Full Stack Server

### Prerequisites

* Check that a python virtual environment has been created and the dependencies (`<full-stack-server>/api/requirements.txt`) have been installed to that environment.

* Ensure that the ubuntu dependencies are installed from the apt.txt file:

```bash
sudo apt-get install -y $(cat <full-stack-server>/api/apt.txt)
```

* Ensure that you placed `.env` file in the `<full-stack-server>/api` directory with the correct parameters. See `<full-stack-server>/api/env_template/env.<server-type>.template` files as examples.

* Ensure that the YAML configuration files are properly set for the server type:

- `<full-stack-server>/api/config/common.yaml` (common parameters for both server types)
- `<full-stack-server>/api/config/<server-type>.yaml` (server type specific parameters)

#### Copy over systemd and environment files

```bash
sudo cp <full-stack-server>/api/systemd/neurolibre-<server-type>.service /etc/systemd/system/
sudo cp <full-stack-server>/api/systemd/default/neurolibre-server /etc/default/
```

Make sure that the `neurolibre-server` file has correct permissions after copying:

```bash
sudo chown ubuntu:ubuntu /etc/default/neurolibre-server
sudo chmod 644 /etc/default/neurolibre-server
```

> Note: The `/etc/default/neurolibre-server` file is a shared environment file containing parameters for both server types (preview and preprint).
* Now you can start the service:

```bash
sudo systemctl start neurolibre-<server-type>
```

* Check the status of the service:

```bash
sudo systemctl status neurolibre-<server-type>
```

* Enable the service to start at boot:

```bash
sudo systemctl enable neurolibre-<server-type>
```

##### If the server is not starting

To see the logs:

```bash
sudo journalctl -xn 100 -u neurolibre-<server-type>
```

* Make sure that you copied over the environment file properly with the correct parameters.

* Make sure that the **YAML configuration files** for the respective server corresponds to the resources available in your system.

* If you have made any changes to these, make sure to restart the service for your changes to take effect:

```bash
sudo systemctl restart neurolibre-<server-type>
```

* Make sure that you have a `.env` file.

0 comments on commit 3be9d4d

Please sign in to comment.