jhuckaby/Cronicle

Help setup run cronicle in multi server with centos7, docker, nginx

dangdatmta opened this issue · 2 comments

Summary

Hi guys,
I'm new bie of docker
I want to setup cronicle running on 2 servers with load balancer nginx. But now I get error: WebSocket connection to 'ws://172.19.0.2:3012/socket.io/?EIO=4&transport=websocket' failed: WebSocket is closed before the connection is established.

My Setup

  • Create 2 VM centos 7 with IP: 172.16.10.104, 172.16.10.105

Image of cronicle:

FROM python:3.6

ARG CRONICLE_VERSION=v0.8.28
ENV CRONICLE_VERSION=${CRONICLE_VERSION}

RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
&& apt-get install -y nodejs
&& curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
&& apt-get update && apt-get install -y yarn

RUN curl -s "https://raw.githubusercontent.com/jhuckaby/Cronicle/${CRONICLE_VERSION}/bin/install.js" | node
&& cd /opt/cronicle

EXPOSE 3012
EXPOSE 3014

ENTRYPOINT ["/docker-entrypoint.sh"]

docker-entrypoint.sh

set -e

if [ "$IS_MASTER" = "0" ]
then
echo "Running SLAVE server"
else
echo "Running MASTER server"
/opt/cronicle/bin/control.sh setup
fi

/opt/cronicle/bin/control.sh start

while true;
do
sleep 30;
/opt/cronicle/bin/control.sh status
done

docker-compose.yml in 172.16.10.104

version: '3.2'

services:
loadbalancer:
container_name: loadbalancer
hostname: loadbalancer
image: nginx
volumes:
- ./loadbalancer/nginx.conf:/etc/nginx/nginx.conf
tty: true
links:
- cronicle1
ports:
- 8080:8080
cronicle1:
container_name: cronicle1
hostname: cronicle1
image: cronicle-base
#restart: always
volumes:
- ./sample_conf/config.json:/opt/cronicle/conf/config.json
- ./sample_conf/emails:/opt/cronicle/conf/emails
- ./docker-entrypoint.sh:/docker-entrypoint.sh
- ./backend/cronicle/data:/opt/cronicle/data
entrypoint: /docker-entrypoint.sh
environment:
IS_MASTER: "1"

docker-compose.yml in 172.16.10.105

version: '3.2'

services:
cronicle2:
container_name: cronicle2
hostname: cronicle2
image: cronicle-base
#restart: always
volumes:
- ./sample_conf/config.json:/opt/cronicle/conf/config.json
- ./sample_conf/emails:/opt/cronicle/conf/emails
- ./docker-entrypoint.sh:/docker-entrypoint.sh
- ./backend/cronicle/data:/opt/cronicle/data
entrypoint: /docker-entrypoint.sh
environment:
IS_MASTER: "0"

nginx loadbalancer config

events { worker_connections 1024; }

http {
upstream cronicles {
server cronicle1:3012;
server 172.16.10.105:3012;
}

server {
    listen 8080;

    location / {
        proxy_pass         http://cronicles;
        proxy_set_header   Host $host;
    }
}

}

error

when i access to 172.16.10.104:8080:
Untitled

config.json

{
"base_app_url": "http://loadbalancer:8080",
"email_from": "admin@localhost",
"smtp_hostname": "localhost",
"smtp_port": 25,
"secret_key": "CHANGE_ME",

"log_dir": "logs",
"log_filename": "[component].log",
"log_columns": ["hires_epoch", "date", "hostname", "pid", "component", "category", "code", "msg", "data"],
"log_archive_path": "logs/archives/[yyyy]/[mm]/[dd]/[filename]-[yyyy]-[mm]-[dd].log.gz",
"log_crashes": true,
"copy_job_logs_to": "",
"queue_dir": "queue",
"pid_file": "logs/cronicled.pid",
"debug_level": 9,
"maintenance": "04:00",
"list_row_max": 10000,
"job_data_expire_days": 180,
"child_kill_timeout": 10,
"dead_job_timeout": 120,
"master_ping_freq": 20,
"master_ping_timeout": 60,
"udp_broadcast_port": 3014,
"scheduler_startup_grace": 10,
"universal_web_hook": "",
"track_manual_jobs": false,

"server_comm_use_hostnames": false,
"web_direct_connect": true,
"web_socket_use_hostnames": false,

"job_memory_max": 1073741824,
"job_memory_sustain": 0,
"job_cpu_max": 0,
"job_cpu_sustain": 0,
"job_log_max_size": 0,
"job_env": {},

"web_hook_text_templates": {
	"job_start": "Job started on [hostname]: [event_title] [job_details_url]",
	"job_complete": "Job completed successfully on [hostname]: [event_title] [job_details_url]",
	"job_failure": "Job failed on [hostname]: [event_title]: Error [code]: [description] [job_details_url]",
	"job_launch_failure": "Failed to launch scheduled event: [event_title]: [description] [edit_event_url]"
},

"client": {
	"name": "Cronicle",
	"debug": 1,
	"default_password_type": "password",
	"privilege_list": [
		{ "id": "admin", "title": "Administrator" },
		{ "id": "create_events", "title": "Create Events" },
		{ "id": "edit_events", "title": "Edit Events" },
		{ "id": "delete_events", "title": "Delete Events" },
		{ "id": "run_events", "title": "Run Events" },
		{ "id": "abort_events", "title": "Abort Events" },
		{ "id": "state_update", "title": "Toggle Scheduler" }
	],
	"new_event_template": { 
		"enabled": 1, 
		"params": {}, 
		"timing": { "minutes": [0] },
		"max_children": 1,
		"timeout": 3600,
		"catch_up": 0,
		"queue_max": 1000
	}
},

"Storage": {
	"engine": "Filesystem",
	"list_page_size": 50,
	"concurrency": 4,
	"log_event_types": { "get": 1, "put": 1, "head": 1, "delete": 1, "expire_set": 1 },
	
	"Filesystem": {
		"base_dir": "data",
		"key_namespaces": 1
	}
},

"WebServer": {
	"http_port": 3012,
	"http_htdocs_dir": "htdocs",
	"http_max_upload_size": 104857600,
	"http_static_ttl": 3600,
	"http_static_index": "index.html",
	"http_server_signature": "Cronicle 1.0",
	"http_gzip_text": true,
	"http_timeout": 30,
	"http_regex_json": "(text|javascript|js|json)",
	"http_response_headers": {
		"Access-Control-Allow-Origin": "*"
	},
	
	"https": false,
	"https_port": 3013,
	"https_cert_file": "conf/ssl.crt",
	"https_key_file": "conf/ssl.key",
	"https_force": false,
	"https_timeout": 30,
	"https_header_detect": {
		"Front-End-Https": "^on$",
		"X-Url-Scheme": "^https$",
		"X-Forwarded-Protocol": "^https$",
		"X-Forwarded-Proto": "^https$",
		"X-Forwarded-Ssl": "^on$"
	}
},

"User": {
	"session_expire_days": 30,
	"max_failed_logins_per_hour": 5,
	"max_forgot_passwords_per_hour": 3,
	"free_accounts": false,
	"sort_global_users": true,
	"use_bcrypt": true,
	
	"email_templates": {
		"welcome_new_user": "conf/emails/welcome_new_user.txt",
		"changed_password": "conf/emails/changed_password.txt",
		"recover_password": "conf/emails/recover_password.txt"
	},
	
	"default_privileges": {
		"admin": 0,
		"create_events": 1,
		"edit_events": 1,
		"delete_events": 1,
		"run_events": 0,
		"abort_events": 0,
		"state_update": 0
	}
}

}

Hmmm, I have no idea, but do check out @mikeTWC1984's fork over at: https://github.com/cronicle-edge/cronicle-edge/tree/main/Docker

He seems to have multi-server docker figured out quite nicely (using swarm).