3 ms·
INSERT INTO host (server_id, name, matching) VALUES ( last_insert_rowid(), 'mongrel2.org', '(.).mongrel2.org' ); I love this.
by ErrantX 16y ago
INSERT INTO host (server_id, name, matching)
VALUES (
last_insert_rowid(),
'mongrel2.org',
'(.).mongrel2.org'
);
I love this.
(I can't think of any other way of putting that :))
- cageface 16y agoI'm having a very hard time seeing this as an improvement over apache/nginx/lighttpd text-file configuration. Web server configs also have a tendency to be heirarchical, which sounds extra-painful in SQL. Let's take a real-world nginx conf for example (comments and blank lines elided to save space). I can't imagine how trying to shoehorn something like this into sql is a win. Even Java-style XML situps seem preferable: http { include /usr/local/nginx/conf/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx_access.log main; error_log /var/log/nginx_error.log debug; sendfile on; tcp_nopush on; tcp_nodelay off; gzip on; gzip_http_version 1.0; gzip_comp_level 2; gzip_proxied any; gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; upstream mongrel { server 127.0.0.1:5000; # server 127.0.0.1:5001; # server 127.0.0.1:5002; } server { listen 80; client_max_body_size 50M; root /var/www/apps/mysite.com/current/public; access_log /var/www/apps/mysite.com/shared/log/nginx.vhost.access.log main; if (-f $document_root/system/maintenance.html) { rewrite ^(.*)$ /system/maintenance.html last; break; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect false; proxy_max_temp_file_size 0; if (-f $request_filename) { break; } if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; } if (-f $request_filename.html) { rewrite (.*) $1.html break; } if (!-f $request_filename) { proxy_pass http://mongrel; break; } } error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/apps/mysite.com/current/public; } }
- zedshaw 16y agoFirst off, way to not use a paste site. :-) Second, no, they're not heirarchical, you're just used to them being that way. They're data structures, which are organized however I like them. In nginx they're hierarchical, in Mongrel2 they'll mostly be relational. Third, like I said before, the advantage is tooling. Managing the Mongrel2 configs from other languages, scripts, shells, and remotely with automation will be much easier than what you have in an nginx config. But, here's a thought: What if you could feed an nginx config to a tool and it spit out the Mongrel2 config to replicate it? Wouldn't that be slick?
- ErrantX 16y agoWhen you have to regularly deploy maintain an nginx instance that hosts a large number of small sites you will understand :)
- pedrocr 16y agoThis was the use case I was imagining would be easier with the sql solution. But wouldn't that be best handled by splitting the single .conf file into an hierarchical set of simpler files in directories? Apache vhosts are already handled like that.
- ErrantX 16y ago> Apache vhosts are already handled like that. And they are not much better :) (actually I prefer Nginx - better syntax)