Skip to content

Commit

Permalink
Merge pull request #2 from geniusdynamics/dev
Browse files Browse the repository at this point in the history
@compgeniuses
update websocket name
b08b071
@compgeniuses
update password in create site
684df0a
@compgeniuses
update internal service name
c983fed
@compgeniuses
implement redis before db
f3e6a9d
@compgeniuses
update readme
  • Loading branch information
compgeniuses authored Jun 12, 2024
2 parents 59a6a08 + 785c013 commit dfdaebe
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 55 deletions.
57 changes: 15 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,20 @@
# ns8-kickstart
# ns8-erpnext

This is a template module for [NethServer 8](https://github.com/NethServer/ns8-core).
To start a new module from it:

1. Click on [Use this template](https://github.com/NethServer/ns8-kickstart/generate).
Name your repo with `ns8-` prefix (e.g. `ns8-mymodule`).
Do not end your module name with a number, like ~~`ns8-baaad2`~~!

1. Clone the repository, enter the cloned directory and
[configure your GIT identity](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup#_your_identity)

1. Rename some references inside the repo:
```
modulename=$(basename $(pwd) | sed 's/^ns8-//')
git mv imageroot/systemd/user/kickstart.service imageroot/systemd/user/${modulename}.service
git mv tests/kickstart.robot tests/${modulename}.robot
sed -i "s/kickstart/${modulename}/g" $(find .github/ * -type f)
git commit -a -m "Repository initialization"
```

1. Edit this `README.md` file, by replacing this section with your module
description

1. Adjust `.github/workflows` to your needs. `clean-registry.yml` might
need the proper list of image names to work correctly. Unused workflows
can be disabled from the GitHub Actions interface.

1. Commit and push your local changes

## Install

Instantiate the module with:

add-module ghcr.io/kemboi22/erpnext:latest 1
add-module ghcr.io/geniusdynamics/erpnext:latest 1

The output of the command will return the instance name.
Output example:

{"module_id": "erpnext1", "image_name": "erpnext", "image_url": "ghcr.io/kemboi22/erpnext:latest"}
{"module_id": "erpnext1", "image_name": "erpnext", "image_url": "ghcr.io/geniusdynamics/erpnext:latest"}

## Configure

Let's assume that the mattermost instance is named `kickstart1`.
Let's assume that the mattermost instance is named `erpnext1`.

Launch `configure-module`, by setting the following parameters:
- `host`: a fully qualified domain name for the application
Expand All @@ -54,15 +27,15 @@ Example:
```
api-cli run configure-module --agent module/erpnext1 --data - <<EOF
{
"host": "kickstart.domain.com",
"host": "erpnext.domain.com",
"http2https": true,
"lets_encrypt": false
}
EOF
```

The above command will:
- start and configure the kickstart instance
- start and configure the erpnext instance
- configure a virtual host for trafik to access the instance

## Get the configuration
Expand All @@ -85,10 +58,10 @@ Some configuration settings, like the smarthost setup, are not part of the
Redis keys. To ensure the module is always up-to-date with the
centralized [smarthost
setup](https://nethserver.github.io/ns8-core/core/smarthost/) every time
kickstart starts, the command `bin/discover-smarthost` runs and refreshes
erpnext starts, the command `bin/discover-smarthost` runs and refreshes
the `state/smarthost.env` file with fresh values from Redis.

Furthermore if smarthost setup is changed when kickstart is already
Furthermore if smarthost setup is changed when erpnext is already
running, the event handler `events/smarthost-changed/10reload_services`
restarts the main module service.

Expand All @@ -101,7 +74,7 @@ expected to work: it can be rewritten or discarded completely.

some CLI are needed to debug

- The module runs under an agent that initiate a lot of environment variables (in /home/kickstart1/.config/state), it could be nice to verify them
- The module runs under an agent that initiate a lot of environment variables (in /home/erpnext1/.config/state), it could be nice to verify them
on the root terminal

`runagent -m erpnext1 env`
Expand All @@ -123,7 +96,7 @@ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d292c6ff28e9 localhost/podman-pause:4.6.1-1702418000 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp 80b8de25945f-infra
d8df02bf6f4a docker.io/library/mariadb:10.11.5 --character-set-s... 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp mariadb-app
9e58e5bd676f docker.io/library/nginx:stable-alpine3.17 nginx -g daemon o... 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp kickstart-app
9e58e5bd676f docker.io/library/nginx:stable-alpine3.17 nginx -g daemon o... 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp erpnext-app
```

you can see what environment variable is inside the container
Expand All @@ -133,30 +106,30 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TERM=xterm
PKG_RELEASE=1
MARIADB_DB_HOST=127.0.0.1
MARIADB_DB_NAME=kickstart
MARIADB_DB_NAME=erpnext
MARIADB_IMAGE=docker.io/mariadb:10.11.5
MARIADB_DB_TYPE=mysql
container=podman
NGINX_VERSION=1.24.0
NJS_VERSION=0.7.12
MARIADB_DB_USER=kickstart
MARIADB_DB_PASSWORD=kickstart
MARIADB_DB_USER=erpnext
MARIADB_DB_PASSWORD=erpnext
MARIADB_DB_PORT=3306
HOME=/root
```

you can run a shell inside the container

```
podman exec -ti kickstart-app sh
podman exec -ti erpnext-app sh
/ #
```
## Testing

Test the module using the `test-module.sh` script:


./test-module.sh <NODE_ADDR> ghcr.io/nethserver/kickstart:latest
./test-module.sh <NODE_ADDR> ghcr.io/nethserver/erpnext:latest

The tests are made using [Robot Framework](https://robotframework.org/)

Expand Down
4 changes: 2 additions & 2 deletions imageroot/systemd/user/backend.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#

[Unit]
Description=Podman erp-next-backend.service
Description=Podman backend.service
Requires=erp-next.service
After=erp-next.service db.service redis-queue.service
After=erp-next.service redis-queue.service db.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/configurator.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

[Unit]
Description=Podman erp-next-configurator.service
Description=Podman configurator.service
Requires=erp-next.service
After=erp-next.service redis-queue.service db.service backend.service

Expand Down
4 changes: 2 additions & 2 deletions imageroot/systemd/user/create-site.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=Podman erp-next-create-site.service
Description=Podman create-site.service
Requires=erp-next.service
After=erp-next.service redis-queue.service db.service backend.service configurator.service

Expand Down Expand Up @@ -30,7 +30,7 @@ ExecStart=/usr/bin/podman run --conmon-pidfile %t/create-site.pid \
fi
done;
echo "sites/common_site_config.json found";
bench new-site --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default frontend;
bench new-site --no-mariadb-socket --admin-password=erpnext --db-root-password=erpnext --install-app erpnext --set-default frontend;
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/create-site.ctr-id -t 10
ExecReload=/usr/bin/podman kill -s HUP create-site
SyslogIdentifier=%u
Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/db.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

[Unit]
Description=Podman mariadb-app.service
Description=Podman db.service
BindsTo=erp-next.service
After=erp-next.service redis-queue.service

Expand Down
4 changes: 2 additions & 2 deletions imageroot/systemd/user/erp-next.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

[Unit]
Description=Podman erp-next.service
Requires=redis-queue.service db.service backend.service configurator.service create-site.service frontend.service queue-long.service queue-short.service scheduler.service wesocket.service
Before=redis-queue.service db.service backend.service configurator.service create-site.service frontend.service queue-long.service queue-short.service scheduler.service wesocket.service
Requires=redis-queue.service db.service backend.service configurator.service create-site.service frontend.service queue-long.service queue-short.service scheduler.service websocket.service
Before=redis-queue.service db.service backend.service configurator.service create-site.service frontend.service queue-long.service queue-short.service scheduler.service websocket.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/frontend.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frontend.service

[Unit]
Description=Podman erp-next-frontend.service
Description=Podman frontend.service
Requires=erp-next.service
After=erp-next.service redis-queue.service db.service backend.service configurator.service create-site.service

Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/queue-long.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# queue-long.service

[Unit]
Description=Podman erp-next-queue-long.service
Description=Podman queue-long.service
Requires=erp-next.service
After=erp-next.service redis-queue.service db.service backend.service configurator.service create-site.service frontend.service

Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/queue-short.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# queue-short.service

[Unit]
Description=Podman erp-next-queue-short.service
Description=Podman queue-short.service
Requires=erp-next.service
After=erp-next.service redis-queue.service db.service backend.service configurator.service create-site.service frontend.service queue-long.service

Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/redis-queue.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# redis-queue.service

[Unit]
Description=Podman erp-next-redis-queue.service
Description=Podman redis-queue.service
Requires=erp-next.service
After=erp-next.service
[Service]
Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/scheduler.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# scheduler.service

[Unit]
Description=Podman erp-next-scheduler.service
Description=Podman scheduler.service
Requires=erp-next.service
After=erp-next.service redis-queue.service db.service backend.service configurator.service create-site.service frontend.service queue-long.service queue-short.service

Expand Down

0 comments on commit dfdaebe

Please sign in to comment.