Skip to content

Commit b452d05

Browse files
committed
Add nginx and docker to supervisor with instructions to autostart on
running Docker container
1 parent 5935dd4 commit b452d05

File tree

3 files changed

+34
-116
lines changed

3 files changed

+34
-116
lines changed

Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ WORKDIR /opt
1111

1212
# Move all code into Tango directory
1313
ADD . TangoService/Tango/
14-
RUN mkdir /volumes
15-
16-
# Install dependancies
17-
# supervisor installed and works
14+
WORKDIR /opt/TangoService/Tango
15+
RUN mkdir volumes
1816

17+
WORKDIR /opt
1918

19+
# Install dependancies
2020
RUN apt-get update && apt-get install -y \
2121
nginx \
2222
curl \
@@ -37,8 +37,7 @@ RUN apt-get update && apt-get install -y \
3737
&& apt-get clean \
3838
&& rm -rf /var/lib/apt/lists/*
3939

40-
ENV PATH /usr/local/nginx/sbin/ngnix:$PATH
41-
40+
# Install Redis
4241
RUN wget http://download.redis.io/releases/redis-stable.tar.gz && tar xzf redis-stable.tar.gz
4342
WORKDIR /opt/redis-stable
4443
RUN make && make install
@@ -53,22 +52,22 @@ RUN chmod +x /usr/local/bin/wrapdocker
5352

5453
# Define additional metadata for our image.
5554
VOLUME /var/lib/docker
56-
CMD ["wrapdocker"]
5755

5856
# Create virtualenv to link dependancies
5957
RUN pip install virtualenv && virtualenv .
6058
# Install python dependancies
6159
RUN pip install -r requirements.txt
6260

61+
RUN mkdir -p /var/log/docker /var/log/supervisor
62+
6363
# Move custom config file to proper location
6464
RUN cp /opt/TangoService/Tango/deployment/config/nginx.conf /etc/nginx/nginx.conf
6565
RUN cp /opt/TangoService/Tango/deployment/config/supervisord.conf /etc/supervisor/supervisord.conf
6666
RUN cp /opt/TangoService/Tango/deployment/config/redis.conf /etc/redis.conf
6767

68-
68+
EXPOSE 8600
6969
# Reload new config scripts
70-
RUN service nginx start
71-
RUN service supervisor start
70+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
7271

7372

7473
# TODO:

deployment/config/nginx.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
#user nobody;
33
worker_processes 1;
4+
daemon off;
45

56
#error_log logs/error.log;
67
#error_log logs/error.log notice;

deployment/config/supervisord.conf

Lines changed: 24 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
; Sample supervisor config file.
2-
;
3-
; For more information on the config file, please see:
4-
; http://supervisord.org/configuration.html
5-
;
6-
; Notes:
7-
; - Shell expansion ("~" or "$HOME") is not supported. Environment
8-
; variables can be expanded using this syntax: "%(ENV_HOME)s".
9-
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
1+
; Supervisor config file.
102

113
[unix_http_server]
124
file=/tmp/supervisor.sock ; (the path to the socket file)
@@ -15,18 +7,13 @@ file=/tmp/supervisor.sock ; (the path to the socket file)
157
;username=user ; (default is no username (open server))
168
;password=123 ; (default is no password (open server))
179

18-
;[inet_http_server] ; inet (TCP) server disabled by default
19-
;port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
20-
;username=user ; (default is no username (open server))
21-
;password=123 ; (default is no password (open server))
22-
2310
[supervisord]
2411
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
2512
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
2613
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
2714
loglevel=info ; (log level;default info; others: debug,warn,trace)
2815
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
29-
nodaemon=false ; (start in foreground if true;default false)
16+
nodaemon=true ; (start in foreground if true;default false)
3017
minfds=1024 ; (min. avail startup file descriptors;default 1024)
3118
minprocs=200 ; (min. avail process descriptors;default 200)
3219
;umask=022 ; (process file creation umask;default 022)
@@ -52,111 +39,42 @@ serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
5239
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
5340
;history_file=~/.sc_history ; use readline history if available
5441

55-
; The below sample program section shows all possible program subsection values,
56-
; create one or more 'real' program: sections to be able to control them under
57-
; supervisor.
58-
59-
;[program:theprogramname]
60-
;command=/bin/cat ; the program (relative uses PATH, can take args)
61-
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
62-
;numprocs=1 ; number of processes copies to start (def 1)
63-
;directory=/tmp ; directory to cwd to before exec (def no cwd)
64-
;umask=022 ; umask for process (default None)
65-
;priority=999 ; the relative start priority (default 999)
66-
;autostart=true ; start at supervisord start (default: true)
67-
;autorestart=unexpected ; whether/when to restart (default: unexpected)
68-
;startsecs=1 ; number of secs prog must stay running (def. 1)
69-
;startretries=3 ; max # of serial start failures (default 3)
70-
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
71-
;stopsignal=QUIT ; signal used to kill process (default TERM)
72-
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
73-
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
74-
;killasgroup=false ; SIGKILL the UNIX process group (def false)
75-
;user=chrism ; setuid to this UNIX account to run the program
76-
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
77-
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
78-
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
79-
;stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
80-
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
81-
;stdout_events_enabled=false ; emit events on stdout writes (default false)
82-
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
83-
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
84-
;stderr_logfile_backups=10 ; # of stderr logfile backups (default 10)
85-
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
86-
;stderr_events_enabled=false ; emit events on stderr writes (default false)
87-
;environment=A="1",B="2" ; process environment additions (def no adds)
88-
;serverurl=AUTO ; override serverurl computation (childutils)
89-
90-
; The below sample eventlistener section shows all possible
91-
; eventlistener subsection values, create one or more 'real'
92-
; eventlistener: sections to be able to handle event notifications
93-
; sent by supervisor.
94-
95-
;[eventlistener:theeventlistenername]
96-
;command=/bin/eventlistener ; the program (relative uses PATH, can take args)
97-
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
98-
;numprocs=1 ; number of processes copies to start (def 1)
99-
;events=EVENT ; event notif. types to subscribe to (req'd)
100-
;buffer_size=10 ; event buffer queue size (default 10)
101-
;directory=/tmp ; directory to cwd to before exec (def no cwd)
102-
;umask=022 ; umask for process (default None)
103-
;priority=-1 ; the relative start priority (default -1)
104-
;autostart=true ; start at supervisord start (default: true)
105-
;autorestart=unexpected ; whether/when to restart (default: unexpected)
106-
;startsecs=1 ; number of secs prog must stay running (def. 1)
107-
;startretries=3 ; max # of serial start failures (default 3)
108-
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
109-
;stopsignal=QUIT ; signal used to kill process (default TERM)
110-
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
111-
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
112-
;killasgroup=false ; SIGKILL the UNIX process group (def false)
113-
;user=chrism ; setuid to this UNIX account to run the program
114-
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
115-
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
116-
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
117-
;stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
118-
;stdout_events_enabled=false ; emit events on stdout writes (default false)
119-
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
120-
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
121-
;stderr_logfile_backups ; # of stderr logfile backups (default 10)
122-
;stderr_events_enabled=false ; emit events on stderr writes (default false)
123-
;environment=A="1",B="2" ; process environment additions
124-
;serverurl=AUTO ; override serverurl computation (childutils)
125-
126-
; The below sample group section shows all possible group values,
127-
; create one or more 'real' group: sections to create "heterogeneous"
128-
; process groups.
129-
130-
;[group:thegroupname]
131-
;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
132-
;priority=999 ; the relative start priority (default 999)
133-
134-
; The [include] section can just contain the "files" setting. This
135-
; setting can list multiple files (separated by whitespace or
136-
; newlines). It can also contain wildcards. The filenames are
137-
; interpreted as relative to this file. Included files *cannot*
138-
; include files themselves.
139-
140-
;[include]
141-
;files = relative/directory/*.ini
142-
14342
[program:redis_server]
14443
command=/usr/local/bin/redis-server /etc/redis.conf
145-
autostart=false
44+
priority=1
45+
autostart=true
14646
autorestart=false
14747
user=root
14848
stdout_logfile=/var/log/redis_stdout.log
14949
stderr_logfile=/var/log/redis_stderr.log
15050

51+
[program:nginx]
52+
command=/usr/sbin/nginx -c /etc/nginx/nginx.conf
53+
autostart=true
54+
autorestart=true
55+
stdout_events_enabled=true
56+
stderr_events_enabled=true
57+
58+
[program:docker]
59+
command=/usr/bin/docker daemon
60+
autostart=true
61+
autorestart=true
62+
user=root
63+
redirect_stderr=true
64+
stdout_logfile=/var/log/docker/%(program_name)s.log
65+
stdout_logfile_maxbytes=10MB
66+
stdout_logfile_backups=10
15167

15268
[program:tango]
153-
command=python /opt/TangoService/Tango/restful-tango/server.py 861%(process_num)01d
69+
command=/bin/bash -c 'sleep 5 && python /opt/TangoService/Tango/restful-tango/server.py 861%(process_num)01d'
70+
autostart=true
15471
process_name=%(process_num)01d
15572
redirect_stderr=true
15673
stdout_logfile=/opt/TangoService/tango_log.log.%(process_num)01d
15774
numprocs=2
15875

15976
[program:tangoJobManager]
160-
command=python /opt/TangoService/Tango/jobManager.py
77+
command=/bin/bash -c 'sleep 5 && python /opt/TangoService/Tango/jobManager.py'
78+
autostart=true
16179
redirect_stderr=true
16280
stdout_logfile=/opt/TangoService/tango_job_manager_log.log

0 commit comments

Comments
 (0)