From fe70a7e616f6078f677ff01ac85a9c6e5b7cc003 Mon Sep 17 00:00:00 2001 From: karim hamidou Date: Thu, 5 Dec 2013 20:14:47 +0100 Subject: [PATCH] WIP - wrestling with the ubuntu supervisord package --- manifests/default.pp | 4 ++- puppet_modules/supervisord/manifests/init.pp | 6 ++-- .../supervisord/templates/nginx_config.erb | 32 ------------------- .../templates/supervisord.conf.erb | 9 +++--- src/back/kite/filterdaemon.py | 3 ++ 5 files changed, 13 insertions(+), 41 deletions(-) delete mode 100644 puppet_modules/supervisord/templates/nginx_config.erb mode change 100644 => 100755 src/back/kite/filterdaemon.py diff --git a/manifests/default.pp b/manifests/default.pp index 585efd5..a8623bd 100644 --- a/manifests/default.pp +++ b/manifests/default.pp @@ -84,7 +84,9 @@ class {'dovecot': } class {'supervisord': - maildirs => '/home/kite/Maildirs' + maildirs => '/home/kite/Maildirs/kitebox.dev/testuser', #FIXME: revert to Maildirs when multiple users are supported + appdir => "/home/kite/app/back/kite/", + require => File["/home/kite/app"] } # deploy files diff --git a/puppet_modules/supervisord/manifests/init.pp b/puppet_modules/supervisord/manifests/init.pp index 2ccc451..c6fac47 100644 --- a/puppet_modules/supervisord/manifests/init.pp +++ b/puppet_modules/supervisord/manifests/init.pp @@ -1,6 +1,6 @@ # a class for installing and configuring a basic nginx setup -class supervisord ($maildirs) { +class supervisord ($maildirs, $appdir) { $packages = ["supervisor"] package { $packages: @@ -10,7 +10,7 @@ class supervisord ($maildirs) { file {"/etc/supervisord.conf": owner => "root", group => "root", - content => template('supervisord/supervisord.conf.erb') + content => template('supervisord/supervisord.conf.erb'), } service {'supervisor': @@ -18,6 +18,6 @@ class supervisord ($maildirs) { enable => true, hasstatus => true, hasrestart => true, - require => Package["supervisor"] + require => [Package["supervisor"], File["/etc/supervisord.conf"]] } } diff --git a/puppet_modules/supervisord/templates/nginx_config.erb b/puppet_modules/supervisord/templates/nginx_config.erb deleted file mode 100644 index b11c3dd..0000000 --- a/puppet_modules/supervisord/templates/nginx_config.erb +++ /dev/null @@ -1,32 +0,0 @@ -server { - listen 80; - server_name _; - access_log /var/log/nginx/<%= server_name %>.access.log; - charset utf-8; - client_max_body_size 8m; - sendfile off; # apparently, it doesn't work so well in virtualized envs. - - gzip_types text/plain text/xml text/css application/javascript application/x-javascript application/json; - - location ^~ /kite { - proxy_pass http://localhost:8080; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - - location / { - root <%= appdir %>/front/app/; - autoindex off; - expires 1M; - } - - - #error_page 404 /404.html; - - # redirect server error pages to the static page /50x.html - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /var/www/nginx-default; - } -} diff --git a/puppet_modules/supervisord/templates/supervisord.conf.erb b/puppet_modules/supervisord/templates/supervisord.conf.erb index f88fe5a..11058aa 100644 --- a/puppet_modules/supervisord/templates/supervisord.conf.erb +++ b/puppet_modules/supervisord/templates/supervisord.conf.erb @@ -48,9 +48,10 @@ serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket ; create one or more 'real' program: sections to be able to control them under ; supervisor. -;[program:theprogramname] -;command=/bin/cat ; the program (relative uses PATH, can take args) -;process_name=%(program_name)s ; process_name expr (default %(program_name)s) +[program:filterdaemon] +command=<%= appdir %>/filterdaemon.py <%= maildirs %> ; the program (relative uses PATH, can take args) +process_name=filterdaemon_sup ; process_name expr (default %(program_name)s) +stdout_logfile=/tmp/filterdaemon.out ; stdout log path, NONE for none; default AUTO ;numprocs=1 ; number of processes copies to start (def 1) ;directory=/tmp ; directory to cwd to before exec (def no cwd) ;umask=022 ; umask for process (default None) @@ -62,9 +63,7 @@ serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket ;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2) ;stopsignal=QUIT ; signal used to kill process (default TERM) ;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10) -;user=chrism ; setuid to this UNIX account to run the program ;redirect_stderr=true ; redirect proc stderr to stdout (default false) -;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO ;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) ;stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) ;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0) diff --git a/src/back/kite/filterdaemon.py b/src/back/kite/filterdaemon.py old mode 100644 new mode 100755 index facd059..775b212 --- a/src/back/kite/filterdaemon.py +++ b/src/back/kite/filterdaemon.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # filterdaemon.py # This background process creates indexes files for threads and filters. # @@ -109,6 +110,8 @@ class ProcessorThread(threading.Thread): if __name__ == "__main__": path = sys.argv[1] + print "Watching %s..." % path + threads_index = JsonFile(os.path.join(path, "threads_index.json")) if threads_index.data == None: threads_index.data = {} -- 2.43.0