diff --git a/services/nginx.spec b/services/nginx.spec new file mode 100644 index 0000000..0938bde --- /dev/null +++ b/services/nginx.spec @@ -0,0 +1,7 @@ +command: nginx -c ${SERVICE_ROOT}/nginx.conf +provides: www + +#%directory ${SERVICE_ROOT}/ +# name: working directory + +%configuration nginx.conf ${SERVICE_ROOT}/nginx.conf diff --git a/services/www.spec b/services/www.spec new file mode 100644 index 0000000..4362cdb --- /dev/null +++ b/services/www.spec @@ -0,0 +1,5 @@ +command: echo "coucou" +consumes: www + +%directory ${SERVICE_ROOT}/ + name: data directory diff --git a/src/gen-config.cr b/src/gen-config.cr index cb6079a..4acad10 100644 --- a/src/gen-config.cr +++ b/src/gen-config.cr @@ -51,6 +51,7 @@ class GenConfig::Context Environment.load ENVIRONMENTS_DIRECTORY ServiceDefinition.load SERVICES_DIRECTORY Service.load RC_DIRECTORY + Environment.load ENVIRONMENTS_DIRECTORY target_file = File.open target, "w" diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 new file mode 100644 index 0000000..119b48d --- /dev/null +++ b/templates/nginx.conf.j2 @@ -0,0 +1,36 @@ + +# worker_processes 1; +daemon off; + +worker_rlimit_nofile 1024; +events { + worker_connections 800; +} + +http { + error_log /var/log/{{ id | replace("/", "_") }}_error.log warn; + access_log /var/log/{{ id | replace("/", "_") }}_access.log; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + index index.html index.htm index.xhtml; + + fastcgi_param HTTP_PROXY ""; + + keepalive_timeout 65; + + server_tokens off; + + {% for user in consumers["www"] %} + server { + listen {{ port(user.id) }} ; + listen [::]:{{ port(user.id) }} ; + server_name {{ user.domain }} ; + + location / { + root {{ user.root }} ; + } + } + {% endfor %} + +}