Created
January 18, 2016 21:15
-
-
Save jolynch/54db6eb64a8951450d6e to your computer and use it in GitHub Desktop.
An example for how to run Synapse in Docker (not encouraged)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:trusty | |
# Prep | |
RUN echo "deb http://archive.ubuntu.com/ubuntu/ trusty main restricted" > /etc/apt/sources.list | |
RUN echo "deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted" >> /etc/apt/sources.list | |
RUN echo "deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted" >> /etc/apt/sources.list | |
RUN echo "deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted" >> /etc/apt/sources.list | |
RUN echo "deb http://archive.ubuntu.com/ubuntu/ trusty universe" >> /etc/apt/sources.list | |
RUN echo "deb http://archive.ubuntu.com/ubuntu/ trusty-updates universe" >> /etc/apt/sources.list | |
RUN echo "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list | |
RUN apt-get update | |
RUN apt-get install -y software-properties-common && add-apt-repository -y ppa:vbernat/haproxy-1.6 | |
RUN apt-get update | |
RUN apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev zlib1g libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libcurl4-openssl-dev iptables python-pip wget htop psmisc | |
ENV DEBIAN_FRONTEND noninteractive | |
#Install OpenSSL | |
WORKDIR /opt | |
RUN wget https://www.openssl.org/source/latest.tar.gz && tar xfv latest.tar.gz && rm -rf latest.tar.gz | |
RUN mv openssl-* openssl | |
WORKDIR /opt/openssl | |
RUN ./config && make depend && make && make install | |
#Link openssl | |
RUN ln -sf /usr/local/ssl/bin/openssl `which openssl` | |
# Install RUBY | |
WORKDIR /tmp | |
RUN apt-get install -y libffi-dev | |
RUN wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz | |
RUN tar xzfv ruby-2.2.3.tar.gz | |
WORKDIR /tmp/ruby-2.2.3 | |
ENV RUBY_CONFIGURE_OPTS --with-readline-dir=/usr/lib/x86_64-linux-gnu/libreadline.so | |
RUN ./configure | |
RUN make | |
RUN make install | |
RUN echo "gem: --no-ri --no-rdoc" > ~/.gemrc | |
# Install Synapse (fr DB) | |
#RUN gem install synapse | |
RUN gem install specific_install | |
RUN gem specific_install -l https://github.com/airbnb/synapse.git | |
# Install Supervisor | |
RUN apt-get install -y supervisor | |
RUN mkdir -p /var/log/supervisor | |
WORKDIR /opt | |
# Set up the config for Supervisor | |
ADD supervisord.conf /etc/supervisor/ | |
# Add Synapse Config | |
ADD synapse.conf.json /etc/synapse.conf.json | |
# Install HAProxy | |
RUN apt-get install -y haproxy | |
RUN mkdir /var/haproxy | |
EXPOSE 3212 | |
ENTRYPOINT ["/usr/bin/supervisord"] | |
CMD ["-c", "/etc/supervisor/supervisord.conf"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@00fab8dceae8:/opt# ps axuf | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
root 28 1.0 0.0 18144 3120 ? Ss 21:09 0:00 /bin/bash | |
root 41 0.0 0.0 15568 2208 ? R+ 21:09 0:00 \_ ps axuf | |
root 1 0.1 0.1 52120 16704 ? Ss 21:08 0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/superv | |
root 8 0.2 0.0 485848 16116 ? Sl 21:08 0:00 /usr/local/bin/ruby /usr/local/bin/synapse -c /etc/synapse.con | |
root 20 0.0 0.0 4332 1280 ? S 21:08 0:00 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg | |
root 26 0.0 0.0 28752 5056 ? S 21:08 0:00 \_ /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/hapr | |
root 27 0.0 0.0 28752 3084 ? Ss 21:08 0:00 \_ /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/ | |
root@00fab8dceae8:/opt# ps axuf | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
root 28 0.0 0.0 18144 3280 ? Ss 21:09 0:00 /bin/bash | |
root 47 0.0 0.0 15568 2092 ? R+ 21:09 0:00 \_ ps axuf | |
root 1 0.1 0.1 52120 16704 ? Ss 21:08 0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/superv | |
root 8 0.1 0.0 485848 16304 ? Sl 21:08 0:00 /usr/local/bin/ruby /usr/local/bin/synapse -c /etc/synapse.con | |
root 20 0.0 0.0 4332 1444 ? S 21:08 0:00 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg | |
root 26 0.0 0.0 28752 5056 ? S 21:08 0:00 \_ /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/hapr | |
root 27 0.0 0.0 28752 3084 ? Ss 21:08 0:00 | \_ /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/ | |
root 45 0.0 0.0 28752 5216 ? S 21:09 0:00 \_ /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/hapr | |
root 46 0.0 0.0 28752 904 ? Ss 21:09 0:00 \_ /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/ | |
root@00fab8dceae8:/opt# ps axuf | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
root 28 0.0 0.0 18144 3280 ? Ss 21:09 0:00 /bin/bash | |
root 48 0.0 0.0 15568 2164 ? R+ 21:09 0:00 \_ ps axuf | |
root 1 0.1 0.1 52120 16704 ? Ss 21:08 0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/superv | |
root 8 0.1 0.0 485848 16304 ? Sl 21:08 0:00 /usr/local/bin/ruby /usr/local/bin/synapse -c /etc/synapse.con | |
root 20 0.0 0.0 4332 1444 ? S 21:08 0:00 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg | |
root 45 0.0 0.0 28752 5216 ? S 21:09 0:00 \_ /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/hapr | |
root 46 0.0 0.0 28752 3088 ? Ss 21:09 0:00 \_ /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/ | |
root@00fab8dceae8:/opt# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; supervisor config file | |
[unix_http_server] | |
file=/var/run/supervisor.sock | |
; the below section must remain in the config file for RPC | |
; (supervisorctl/web interface) to work, additional interfaces may be | |
; added by defining them in separate rpcinterface: sections | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[supervisorctl] | |
serverurl=unix:////var/run/supervisor.sock | |
username=supervisord | |
[supervisord] | |
nodaemon=true | |
logfile_maxbytes=5000000 | |
logfile_backups=5 | |
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) | |
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) | |
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) | |
[program:synapse] | |
process_name=synapse | |
command=synapse -c /etc/synapse.conf.json | |
numproces=1 | |
stopasgroup=true | |
autorestart=unexpected | |
priority=999 | |
stdout_logfile=/var/log/supervisor/synapse.log | |
stdout_logfile_maxbytes=5000000 | |
stdout_logfile_backups=5 | |
redirect_stderr=true | |
stopsignal=QUIT | |
[program:haproxy] | |
process_name=haproxy | |
command=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /var/haproxy/haproxy.pid | |
numprocs=1 | |
stopasgroup=false | |
priority=101 | |
autostart=true | |
autorestart=true | |
stdout_logfile=/var/log/supervisor/haproxy.log | |
stdout_logfile_maxbytes=5000000 | |
stdout_logfile_backups=5 | |
redirect_stderr=true | |
stopsignal=TERM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"services": { | |
"zk_service": { | |
"default_servers": [], | |
"use_previous_backends": false, | |
"discovery": { | |
"method": "zookeeper", | |
"path": "/services/zk_service", | |
"hosts": [ | |
"169.254.255.254:2181" | |
] | |
}, | |
"haproxy": { | |
"port": 1234, | |
"backend_name": "zk_service", | |
"listen": [ | |
"mode http" | |
] | |
} | |
} | |
}, | |
"haproxy": { | |
"reload_command": "/bin/kill -USR2 $(pgrep haproxy-systemd)", | |
"config_file_path": "/etc/haproxy/haproxy.cfg", | |
"socket_file_path": "/tmp/haproxy.sock", | |
"global": [ | |
"daemon", | |
"maxconn 4096", | |
"stats socket /tmp/haproxy.sock mode 666 level admin" | |
], | |
"defaults": [ | |
"log global", | |
"option dontlognull", | |
"maxconn 2000", | |
"retries 3", | |
"timeout connect 5s", | |
"timeout client 3s", | |
"timeout server 3s", | |
"option redispatch", | |
"balance roundrobin" | |
], | |
"extra_sections": { | |
"listen stats": [ | |
"bind :3212", | |
"mode http", | |
"stats enable", | |
"stats uri /", | |
"stats refresh 5s" | |
] | |
} | |
}, | |
"file_output": { | |
"output_directory": "/tmp/synapse" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment