From 7faad21fa471e0a233e01ae567324282351cf5f9 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Sun, 19 Jul 2015 09:43:35 +0530 Subject: [PATCH] Add socketio config --- bench/config.py | 4 +++- bench/templates/nginx.conf | 11 +++++++++++ bench/templates/supervisor.conf | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/bench/config.py b/bench/config.py index c39b4322..0309502f 100644 --- a/bench/config.py +++ b/bench/config.py @@ -3,6 +3,7 @@ import getpass import json import subprocess import shutil +from distutils.spawn import find_executable from jinja2 import Environment, PackageLoader from .utils import get_sites, get_config, update_config, get_redis_version @@ -35,7 +36,8 @@ def generate_supervisor_config(bench='.', user=None): "sites_dir": sites_dir, "user": user, "http_timeout": config.get("http_timeout", 120), - "redis_server": subprocess.check_output('which redis-server', shell=True).strip(), + "redis_server": find_executable('redis-server'), + "node": find_executable('node'), "redis_cache_config": os.path.join(bench_dir, 'config', 'redis_cache.conf'), "redis_async_broker_config": os.path.join(bench_dir, 'config', 'redis_async_broker.conf'), "frappe_version": get_current_frappe_version() diff --git a/bench/templates/nginx.conf b/bench/templates/nginx.conf index 2236a6e4..93f87bae 100644 --- a/bench/templates/nginx.conf +++ b/bench/templates/nginx.conf @@ -5,6 +5,10 @@ upstream frappe { server 127.0.0.1:8000 fail_timeout=0; } +upstream socketio-server { + server 127.0.0.1:3000 fail_timeout=0; +} + {% macro location_block(site, port=80, default=False, server_name=None, sites=None, dns_multitenant=False) -%} keepalive_timeout 5; sendfile on; @@ -19,6 +23,13 @@ upstream frappe { try_files $uri =404; } + location /socket.io { + proxy_pass http://socketio-server; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + location / { try_files /{{ "$host" if dns_multitenant else site.name }}/public/$uri @magic; } diff --git a/bench/templates/supervisor.conf b/bench/templates/supervisor.conf index e24e42c3..a2519318 100644 --- a/bench/templates/supervisor.conf +++ b/bench/templates/supervisor.conf @@ -51,6 +51,19 @@ stdout_logfile={{ bench_dir }}/logs/redis-async-broker.log stderr_logfile={{ bench_dir }}/logs/redis-async-broker.error.log user={{ user }} directory={{ sites_dir }} + +{% if node %} +[program:node-socketio] +command={{ node }} apps/frappe/socketio.js +autostart=true +autorestart=true +stopsignal=QUIT +stdout_logfile={{ bench_dir }}/logs/node-socketio.log +stderr_logfile={{ bench_dir }}/logs/node-socketio.error.log +user={{ user }} +directory={{ sites_dir }} +{% endif %} + {% endif %} [group:frappe]