Add posibility for multiple nodes

pull/718/head
nchamo 2019-08-14 13:24:07 -03:00
rodzic a6979e46b3
commit f287715d7c
6 zmienionych plików z 44 dodań i 12 usunięć

1
.env
Wyświetl plik

@ -8,3 +8,4 @@ WO_SSL_INSECURE_PORT_REDIRECT=80
WO_DEBUG=NO
WO_DEV=NO
WO_BROKER=redis://broker
WO_DEFAULT_NODES=1

Wyświetl plik

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
from nodeodm.models import ProcessingNode
def rename_default_node(apps, schema_editor):
for default_node in ProcessingNode.objects.filter(hostname='node-odm-1'):
default_node.hostname = 'webodm_node-odm_1'
default_node.defaults = {'hostname': 'webodm_node-odm_1', 'port': 3000}
default_node.save()
class Migration(migrations.Migration):
dependencies = [
('app', '0028_task_partial'),
]
operations = [
migrations.RunPython(rename_default_node),
]

Wyświetl plik

@ -6,12 +6,11 @@ version: '2.1'
services:
webapp:
depends_on:
- node-odm-1
- node-odm
environment:
- WO_CREATE_DEFAULT_PNODE=YES
node-odm-1:
- WO_DEFAULT_NODES
node-odm:
image: opendronemap/nodeodm
container_name: node-odm-1
ports:
- "3000"
restart: on-failure:10

@ -1 +0,0 @@
Subproject commit 48cf7f01b2ab96b6fdbdcb81d4ddc5828ae66c0e

Wyświetl plik

@ -57,8 +57,8 @@ fi
echo Running migrations
python manage.py migrate
if [[ "$WO_CREATE_DEFAULT_PNODE" = "YES" ]]; then
echo "from nodeodm.models import ProcessingNode; ProcessingNode.objects.update_or_create(hostname='node-odm-1', defaults={'hostname': 'node-odm-1', 'port': 3000})" | python manage.py shell
if [[ "$WO_DEFAULT_NODES" > 0 ]]; then
echo -e "from nodeodm.models import ProcessingNode\nfor node_index in map(str, range(1, $WO_DEFAULT_NODES + 1)):\n\t ProcessingNode.objects.update_or_create(hostname='webodm_node-odm_' + node_index, defaults={'hostname': 'webodm_node-odm_' + node_index, 'port': 3000})" | python manage.py shell
fi
if [[ "$WO_CREATE_MICMAC_PNODE" = "YES" ]]; then

Wyświetl plik

@ -18,7 +18,7 @@ if [[ $platform = "Windows" ]]; then
export COMPOSE_CONVERT_WINDOWS_PATHS=1
fi
load_default_node=true
default_nodes=1
dev_mode=false
# Load default values
@ -87,7 +87,8 @@ case $key in
shift # past value
;;
--no-default-node)
load_default_node=false
default_nodes=0
export WO_DEFAULT_NODES=0
shift # past argument
;;
--with-micmac)
@ -98,6 +99,12 @@ case $key in
detached=true
shift # past argument
;;
--default-nodes)
default_nodes="$2"
export WO_DEFAULT_NODES="$2"
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
@ -125,7 +132,8 @@ usage(){
echo " --port <port> Set the port that WebODM should bind to (default: $DEFAULT_PORT)"
echo " --hostname <hostname> Set the hostname that WebODM will be accessible from (default: $DEFAULT_HOST)"
echo " --media-dir <path> Path where processing results will be stored to (default: $DEFAULT_MEDIA_DIR (docker named volume))"
echo " --no-default-node Do not create a default NodeODM node attached to WebODM on startup (default: disabled)"
echo " --no-default-node Do not create a default NodeODM node attached to WebODM on startup (default: disabled). DEPRECATED: please use the argument 'default-nodes'"
echo " --default-nodes The amount of default NodeODM nodes attached to WebODM on startup (default: 1)"
echo " --with-micmac Create a NodeMICMAC node attached to WebODM on startup. Experimental! (default: disabled)"
echo " --ssl Enable SSL and automatically request and install a certificate from letsencrypt.org. (default: $DEFAULT_SSL)"
echo " --ssl-key <path> Manually specify a path to the private key file (.pem) to use with nginx to enable SSL (default: None)"
@ -199,7 +207,7 @@ start(){
command="docker-compose -f docker-compose.yml"
if [[ $load_default_node = true ]]; then
if [[ $default_nodes > 0 ]]; then
command+=" -f docker-compose.nodeodm.yml"
fi
@ -255,6 +263,10 @@ start(){
command+=" -d"
fi
if [[ $default_nodes > 0 ]]; then
command+=" --scale node-odm=$default_nodes"
fi
run "$command"
}
@ -338,7 +350,7 @@ elif [[ $1 = "update" ]]; then
command="docker-compose -f docker-compose.yml"
if [[ $load_default_node = true ]]; then
if [[ $default_nodes > 0 ]]; then
command+=" -f docker-compose.nodeodm.yml"
fi