Skip to content

Commit

Permalink
Add posibility for multiple nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
nchamo committed Aug 14, 2019
1 parent a6979e4 commit f287715
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ WO_SSL_INSECURE_PORT_REDIRECT=80
WO_DEBUG=NO
WO_DEV=NO
WO_BROKER=redis://broker
WO_DEFAULT_NODES=1
21 changes: 21 additions & 0 deletions app/migrations/0029_rename_default_odm_node.py
Original file line number Diff line number Diff line change
@@ -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),
]
7 changes: 3 additions & 4 deletions docker-compose.nodeodm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion nodeodm/external/NodeODM
Submodule NodeODM deleted from 48cf7f
4 changes: 2 additions & 2 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 17 additions & 5 deletions webodm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -255,6 +263,10 @@ start(){
command+=" -d"
fi

if [[ $default_nodes > 0 ]]; then
command+=" --scale node-odm=$default_nodes"
fi

run "$command"
}

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit f287715

Please sign in to comment.