nginxtra 1.0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -0
- data/bin/nginxtra +5 -0
- data/lib/nginxtra.rb +12 -0
- data/lib/nginxtra/action.rb +36 -0
- data/lib/nginxtra/actions/compile.rb +60 -0
- data/lib/nginxtra/actions/install.rb +99 -0
- data/lib/nginxtra/actions/reload.rb +14 -0
- data/lib/nginxtra/actions/restart.rb +15 -0
- data/lib/nginxtra/actions/start.rb +53 -0
- data/lib/nginxtra/actions/status.rb +31 -0
- data/lib/nginxtra/actions/stop.rb +14 -0
- data/lib/nginxtra/cli.rb +77 -0
- data/lib/nginxtra/config.rb +339 -0
- data/lib/nginxtra/error.rb +13 -0
- data/lib/nginxtra/status.rb +57 -0
- data/src/nginx/CHANGES +5630 -0
- data/src/nginx/CHANGES.ru +5716 -0
- data/src/nginx/LICENSE +25 -0
- data/src/nginx/README +3 -0
- data/src/nginx/auto/cc/acc +15 -0
- data/src/nginx/auto/cc/bcc +72 -0
- data/src/nginx/auto/cc/ccc +46 -0
- data/src/nginx/auto/cc/conf +189 -0
- data/src/nginx/auto/cc/gcc +183 -0
- data/src/nginx/auto/cc/icc +121 -0
- data/src/nginx/auto/cc/msvc +138 -0
- data/src/nginx/auto/cc/name +101 -0
- data/src/nginx/auto/cc/owc +104 -0
- data/src/nginx/auto/cc/sunc +158 -0
- data/src/nginx/auto/define +12 -0
- data/src/nginx/auto/endianess +45 -0
- data/src/nginx/auto/feature +123 -0
- data/src/nginx/auto/have +12 -0
- data/src/nginx/auto/have_headers +12 -0
- data/src/nginx/auto/headers +13 -0
- data/src/nginx/auto/include +61 -0
- data/src/nginx/auto/init +51 -0
- data/src/nginx/auto/install +184 -0
- data/src/nginx/auto/lib/conf +83 -0
- data/src/nginx/auto/lib/geoip/conf +79 -0
- data/src/nginx/auto/lib/google-perftools/conf +45 -0
- data/src/nginx/auto/lib/libatomic/conf +43 -0
- data/src/nginx/auto/lib/libatomic/make +14 -0
- data/src/nginx/auto/lib/libgd/conf +83 -0
- data/src/nginx/auto/lib/libxslt/conf +156 -0
- data/src/nginx/auto/lib/make +32 -0
- data/src/nginx/auto/lib/md5/conf +103 -0
- data/src/nginx/auto/lib/md5/make +96 -0
- data/src/nginx/auto/lib/md5/makefile.bcc +22 -0
- data/src/nginx/auto/lib/md5/makefile.msvc +22 -0
- data/src/nginx/auto/lib/md5/makefile.owc +11 -0
- data/src/nginx/auto/lib/openssl/conf +74 -0
- data/src/nginx/auto/lib/openssl/make +67 -0
- data/src/nginx/auto/lib/openssl/makefile.bcc +18 -0
- data/src/nginx/auto/lib/openssl/makefile.msvc +14 -0
- data/src/nginx/auto/lib/pcre/conf +180 -0
- data/src/nginx/auto/lib/pcre/make +64 -0
- data/src/nginx/auto/lib/pcre/makefile.bcc +26 -0
- data/src/nginx/auto/lib/pcre/makefile.msvc +22 -0
- data/src/nginx/auto/lib/pcre/makefile.owc +24 -0
- data/src/nginx/auto/lib/perl/conf +60 -0
- data/src/nginx/auto/lib/perl/make +36 -0
- data/src/nginx/auto/lib/sha1/conf +79 -0
- data/src/nginx/auto/lib/sha1/make +96 -0
- data/src/nginx/auto/lib/sha1/makefile.bcc +22 -0
- data/src/nginx/auto/lib/sha1/makefile.msvc +22 -0
- data/src/nginx/auto/lib/sha1/makefile.owc +11 -0
- data/src/nginx/auto/lib/test +40 -0
- data/src/nginx/auto/lib/zlib/conf +76 -0
- data/src/nginx/auto/lib/zlib/make +114 -0
- data/src/nginx/auto/lib/zlib/makefile.bcc +15 -0
- data/src/nginx/auto/lib/zlib/makefile.msvc +14 -0
- data/src/nginx/auto/lib/zlib/makefile.owc +14 -0
- data/src/nginx/auto/lib/zlib/patch.zlib.h +10 -0
- data/src/nginx/auto/make +417 -0
- data/src/nginx/auto/modules +479 -0
- data/src/nginx/auto/nohave +12 -0
- data/src/nginx/auto/options +490 -0
- data/src/nginx/auto/os/conf +105 -0
- data/src/nginx/auto/os/darwin +116 -0
- data/src/nginx/auto/os/freebsd +136 -0
- data/src/nginx/auto/os/linux +152 -0
- data/src/nginx/auto/os/solaris +60 -0
- data/src/nginx/auto/os/win32 +29 -0
- data/src/nginx/auto/sources +518 -0
- data/src/nginx/auto/stubs +8 -0
- data/src/nginx/auto/summary +114 -0
- data/src/nginx/auto/types/sizeof +83 -0
- data/src/nginx/auto/types/typedef +77 -0
- data/src/nginx/auto/types/uintptr_t +42 -0
- data/src/nginx/auto/types/value +12 -0
- data/src/nginx/auto/unix +719 -0
- data/src/nginx/conf/fastcgi.conf +24 -0
- data/src/nginx/conf/fastcgi_params +23 -0
- data/src/nginx/conf/koi-utf +109 -0
- data/src/nginx/conf/koi-win +103 -0
- data/src/nginx/conf/mime.types +80 -0
- data/src/nginx/conf/nginx.conf +118 -0
- data/src/nginx/conf/scgi_params +15 -0
- data/src/nginx/conf/uwsgi_params +15 -0
- data/src/nginx/conf/win-utf +126 -0
- data/src/nginx/configure +108 -0
- data/src/nginx/contrib/README +15 -0
- data/src/nginx/contrib/geo2nginx.pl +58 -0
- data/src/nginx/contrib/unicode2nginx/koi-utf +131 -0
- data/src/nginx/contrib/unicode2nginx/unicode-to-nginx.pl +45 -0
- data/src/nginx/contrib/unicode2nginx/win-utf +130 -0
- data/src/nginx/html/50x.html +18 -0
- data/src/nginx/html/index.html +8 -0
- data/src/nginx/man/nginx.8 +202 -0
- data/src/nginx/src/core/nginx.c +1333 -0
- data/src/nginx/src/core/nginx.h +20 -0
- data/src/nginx/src/core/ngx_array.c +147 -0
- data/src/nginx/src/core/ngx_array.h +53 -0
- data/src/nginx/src/core/ngx_buf.c +218 -0
- data/src/nginx/src/core/ngx_buf.h +162 -0
- data/src/nginx/src/core/ngx_conf_file.c +1506 -0
- data/src/nginx/src/core/ngx_conf_file.h +348 -0
- data/src/nginx/src/core/ngx_config.h +134 -0
- data/src/nginx/src/core/ngx_connection.c +1074 -0
- data/src/nginx/src/core/ngx_connection.h +195 -0
- data/src/nginx/src/core/ngx_core.h +95 -0
- data/src/nginx/src/core/ngx_cpuinfo.c +139 -0
- data/src/nginx/src/core/ngx_crc.h +39 -0
- data/src/nginx/src/core/ngx_crc32.c +129 -0
- data/src/nginx/src/core/ngx_crc32.h +79 -0
- data/src/nginx/src/core/ngx_crypt.c +238 -0
- data/src/nginx/src/core/ngx_crypt.h +20 -0
- data/src/nginx/src/core/ngx_cycle.c +1379 -0
- data/src/nginx/src/core/ngx_cycle.h +142 -0
- data/src/nginx/src/core/ngx_file.c +993 -0
- data/src/nginx/src/core/ngx_file.h +151 -0
- data/src/nginx/src/core/ngx_hash.c +976 -0
- data/src/nginx/src/core/ngx_hash.h +122 -0
- data/src/nginx/src/core/ngx_inet.c +1008 -0
- data/src/nginx/src/core/ngx_inet.h +120 -0
- data/src/nginx/src/core/ngx_list.c +71 -0
- data/src/nginx/src/core/ngx_list.h +83 -0
- data/src/nginx/src/core/ngx_log.c +459 -0
- data/src/nginx/src/core/ngx_log.h +250 -0
- data/src/nginx/src/core/ngx_md5.c +289 -0
- data/src/nginx/src/core/ngx_md5.h +60 -0
- data/src/nginx/src/core/ngx_murmurhash.c +50 -0
- data/src/nginx/src/core/ngx_murmurhash.h +19 -0
- data/src/nginx/src/core/ngx_open_file_cache.c +882 -0
- data/src/nginx/src/core/ngx_open_file_cache.h +119 -0
- data/src/nginx/src/core/ngx_output_chain.c +673 -0
- data/src/nginx/src/core/ngx_palloc.c +433 -0
- data/src/nginx/src/core/ngx_palloc.h +95 -0
- data/src/nginx/src/core/ngx_parse.c +249 -0
- data/src/nginx/src/core/ngx_parse.h +24 -0
- data/src/nginx/src/core/ngx_queue.c +80 -0
- data/src/nginx/src/core/ngx_queue.h +112 -0
- data/src/nginx/src/core/ngx_radix_tree.c +291 -0
- data/src/nginx/src/core/ngx_radix_tree.h +46 -0
- data/src/nginx/src/core/ngx_rbtree.c +383 -0
- data/src/nginx/src/core/ngx_rbtree.h +84 -0
- data/src/nginx/src/core/ngx_regex.c +206 -0
- data/src/nginx/src/core/ngx_regex.h +56 -0
- data/src/nginx/src/core/ngx_resolver.c +2201 -0
- data/src/nginx/src/core/ngx_resolver.h +149 -0
- data/src/nginx/src/core/ngx_sha1.h +31 -0
- data/src/nginx/src/core/ngx_shmtx.c +284 -0
- data/src/nginx/src/core/ngx_shmtx.h +38 -0
- data/src/nginx/src/core/ngx_slab.c +701 -0
- data/src/nginx/src/core/ngx_slab.h +54 -0
- data/src/nginx/src/core/ngx_spinlock.c +53 -0
- data/src/nginx/src/core/ngx_string.c +1837 -0
- data/src/nginx/src/core/ngx_string.h +231 -0
- data/src/nginx/src/core/ngx_times.c +407 -0
- data/src/nginx/src/core/ngx_times.h +51 -0
- data/src/nginx/src/event/modules/ngx_aio_module.c +171 -0
- data/src/nginx/src/event/modules/ngx_devpoll_module.c +569 -0
- data/src/nginx/src/event/modules/ngx_epoll_module.c +833 -0
- data/src/nginx/src/event/modules/ngx_eventport_module.c +602 -0
- data/src/nginx/src/event/modules/ngx_kqueue_module.c +785 -0
- data/src/nginx/src/event/modules/ngx_poll_module.c +443 -0
- data/src/nginx/src/event/modules/ngx_rtsig_module.c +735 -0
- data/src/nginx/src/event/modules/ngx_select_module.c +435 -0
- data/src/nginx/src/event/modules/ngx_win32_select_module.c +400 -0
- data/src/nginx/src/event/ngx_event.c +1275 -0
- data/src/nginx/src/event/ngx_event.h +573 -0
- data/src/nginx/src/event/ngx_event_accept.c +428 -0
- data/src/nginx/src/event/ngx_event_busy_lock.c +286 -0
- data/src/nginx/src/event/ngx_event_busy_lock.h +65 -0
- data/src/nginx/src/event/ngx_event_connect.c +258 -0
- data/src/nginx/src/event/ngx_event_connect.h +76 -0
- data/src/nginx/src/event/ngx_event_mutex.c +70 -0
- data/src/nginx/src/event/ngx_event_openssl.c +2382 -0
- data/src/nginx/src/event/ngx_event_openssl.h +162 -0
- data/src/nginx/src/event/ngx_event_pipe.c +996 -0
- data/src/nginx/src/event/ngx_event_pipe.h +95 -0
- data/src/nginx/src/event/ngx_event_posted.c +173 -0
- data/src/nginx/src/event/ngx_event_posted.h +75 -0
- data/src/nginx/src/event/ngx_event_timer.c +159 -0
- data/src/nginx/src/event/ngx_event_timer.h +102 -0
- data/src/nginx/src/http/modules/ngx_http_access_module.c +384 -0
- data/src/nginx/src/http/modules/ngx_http_addition_filter_module.c +250 -0
- data/src/nginx/src/http/modules/ngx_http_auth_basic_module.c +478 -0
- data/src/nginx/src/http/modules/ngx_http_autoindex_module.c +701 -0
- data/src/nginx/src/http/modules/ngx_http_browser_module.c +713 -0
- data/src/nginx/src/http/modules/ngx_http_charset_filter_module.c +1681 -0
- data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +242 -0
- data/src/nginx/src/http/modules/ngx_http_dav_module.c +1141 -0
- data/src/nginx/src/http/modules/ngx_http_degradation_module.c +243 -0
- data/src/nginx/src/http/modules/ngx_http_empty_gif_module.c +140 -0
- data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +2916 -0
- data/src/nginx/src/http/modules/ngx_http_flv_module.c +254 -0
- data/src/nginx/src/http/modules/ngx_http_geo_module.c +1441 -0
- data/src/nginx/src/http/modules/ngx_http_geoip_module.c +671 -0
- data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +1206 -0
- data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +299 -0
- data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +616 -0
- data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1489 -0
- data/src/nginx/src/http/modules/ngx_http_index_module.c +516 -0
- data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +809 -0
- data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +553 -0
- data/src/nginx/src/http/modules/ngx_http_log_module.c +1357 -0
- data/src/nginx/src/http/modules/ngx_http_map_module.c +575 -0
- data/src/nginx/src/http/modules/ngx_http_memcached_module.c +624 -0
- data/src/nginx/src/http/modules/ngx_http_mp4_module.c +3000 -0
- data/src/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +143 -0
- data/src/nginx/src/http/modules/ngx_http_proxy_module.c +2831 -0
- data/src/nginx/src/http/modules/ngx_http_random_index_module.c +317 -0
- data/src/nginx/src/http/modules/ngx_http_range_filter_module.c +855 -0
- data/src/nginx/src/http/modules/ngx_http_realip_module.c +476 -0
- data/src/nginx/src/http/modules/ngx_http_referer_module.c +613 -0
- data/src/nginx/src/http/modules/ngx_http_rewrite_module.c +1019 -0
- data/src/nginx/src/http/modules/ngx_http_scgi_module.c +1714 -0
- data/src/nginx/src/http/modules/ngx_http_secure_link_module.c +355 -0
- data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +242 -0
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +2913 -0
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.h +114 -0
- data/src/nginx/src/http/modules/ngx_http_ssl_module.c +652 -0
- data/src/nginx/src/http/modules/ngx_http_ssl_module.h +52 -0
- data/src/nginx/src/http/modules/ngx_http_static_module.c +278 -0
- data/src/nginx/src/http/modules/ngx_http_stub_status_module.c +144 -0
- data/src/nginx/src/http/modules/ngx_http_sub_filter_module.c +716 -0
- data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +237 -0
- data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +846 -0
- data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +1774 -0
- data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +984 -0
- data/src/nginx/src/http/modules/perl/Makefile.PL +42 -0
- data/src/nginx/src/http/modules/perl/nginx.pm +137 -0
- data/src/nginx/src/http/modules/perl/nginx.xs +986 -0
- data/src/nginx/src/http/modules/perl/ngx_http_perl_module.c +1076 -0
- data/src/nginx/src/http/modules/perl/ngx_http_perl_module.h +67 -0
- data/src/nginx/src/http/modules/perl/typemap +3 -0
- data/src/nginx/src/http/ngx_http.c +2073 -0
- data/src/nginx/src/http/ngx_http.h +160 -0
- data/src/nginx/src/http/ngx_http_busy_lock.c +307 -0
- data/src/nginx/src/http/ngx_http_busy_lock.h +54 -0
- data/src/nginx/src/http/ngx_http_cache.h +148 -0
- data/src/nginx/src/http/ngx_http_config.h +75 -0
- data/src/nginx/src/http/ngx_http_copy_filter_module.c +300 -0
- data/src/nginx/src/http/ngx_http_core_module.c +4736 -0
- data/src/nginx/src/http/ngx_http_core_module.h +541 -0
- data/src/nginx/src/http/ngx_http_file_cache.c +1715 -0
- data/src/nginx/src/http/ngx_http_header_filter_module.c +623 -0
- data/src/nginx/src/http/ngx_http_parse.c +1734 -0
- data/src/nginx/src/http/ngx_http_parse_time.c +276 -0
- data/src/nginx/src/http/ngx_http_postpone_filter_module.c +178 -0
- data/src/nginx/src/http/ngx_http_request.c +3181 -0
- data/src/nginx/src/http/ngx_http_request.h +573 -0
- data/src/nginx/src/http/ngx_http_request_body.c +644 -0
- data/src/nginx/src/http/ngx_http_script.c +1752 -0
- data/src/nginx/src/http/ngx_http_script.h +257 -0
- data/src/nginx/src/http/ngx_http_special_response.c +789 -0
- data/src/nginx/src/http/ngx_http_upstream.c +4555 -0
- data/src/nginx/src/http/ngx_http_upstream.h +350 -0
- data/src/nginx/src/http/ngx_http_upstream_round_robin.c +791 -0
- data/src/nginx/src/http/ngx_http_upstream_round_robin.h +85 -0
- data/src/nginx/src/http/ngx_http_variables.c +2053 -0
- data/src/nginx/src/http/ngx_http_variables.h +115 -0
- data/src/nginx/src/http/ngx_http_write_filter_module.c +315 -0
- data/src/nginx/src/mail/ngx_mail.c +542 -0
- data/src/nginx/src/mail/ngx_mail.h +407 -0
- data/src/nginx/src/mail/ngx_mail_auth_http_module.c +1452 -0
- data/src/nginx/src/mail/ngx_mail_core_module.c +553 -0
- data/src/nginx/src/mail/ngx_mail_handler.c +773 -0
- data/src/nginx/src/mail/ngx_mail_imap_handler.c +457 -0
- data/src/nginx/src/mail/ngx_mail_imap_module.c +253 -0
- data/src/nginx/src/mail/ngx_mail_imap_module.h +39 -0
- data/src/nginx/src/mail/ngx_mail_parse.c +885 -0
- data/src/nginx/src/mail/ngx_mail_pop3_handler.c +500 -0
- data/src/nginx/src/mail/ngx_mail_pop3_module.c +264 -0
- data/src/nginx/src/mail/ngx_mail_pop3_module.h +38 -0
- data/src/nginx/src/mail/ngx_mail_proxy_module.c +1089 -0
- data/src/nginx/src/mail/ngx_mail_smtp_handler.c +872 -0
- data/src/nginx/src/mail/ngx_mail_smtp_module.c +308 -0
- data/src/nginx/src/mail/ngx_mail_smtp_module.h +45 -0
- data/src/nginx/src/mail/ngx_mail_ssl_module.c +491 -0
- data/src/nginx/src/mail/ngx_mail_ssl_module.h +52 -0
- data/src/nginx/src/misc/ngx_cpp_test_module.cpp +27 -0
- data/src/nginx/src/misc/ngx_google_perftools_module.c +126 -0
- data/src/nginx/src/os/unix/ngx_aio_read.c +109 -0
- data/src/nginx/src/os/unix/ngx_aio_read_chain.c +78 -0
- data/src/nginx/src/os/unix/ngx_aio_write.c +109 -0
- data/src/nginx/src/os/unix/ngx_aio_write_chain.c +100 -0
- data/src/nginx/src/os/unix/ngx_alloc.c +90 -0
- data/src/nginx/src/os/unix/ngx_alloc.h +45 -0
- data/src/nginx/src/os/unix/ngx_atomic.h +311 -0
- data/src/nginx/src/os/unix/ngx_channel.c +258 -0
- data/src/nginx/src/os/unix/ngx_channel.h +34 -0
- data/src/nginx/src/os/unix/ngx_daemon.c +69 -0
- data/src/nginx/src/os/unix/ngx_darwin.h +20 -0
- data/src/nginx/src/os/unix/ngx_darwin_config.h +96 -0
- data/src/nginx/src/os/unix/ngx_darwin_init.c +166 -0
- data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +366 -0
- data/src/nginx/src/os/unix/ngx_errno.c +87 -0
- data/src/nginx/src/os/unix/ngx_errno.h +68 -0
- data/src/nginx/src/os/unix/ngx_file_aio_read.c +208 -0
- data/src/nginx/src/os/unix/ngx_files.c +566 -0
- data/src/nginx/src/os/unix/ngx_files.h +343 -0
- data/src/nginx/src/os/unix/ngx_freebsd.h +24 -0
- data/src/nginx/src/os/unix/ngx_freebsd_config.h +119 -0
- data/src/nginx/src/os/unix/ngx_freebsd_init.c +259 -0
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +756 -0
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +122 -0
- data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +436 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_amd64.h +82 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_ppc.h +155 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +82 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_x86.h +127 -0
- data/src/nginx/src/os/unix/ngx_linux.h +18 -0
- data/src/nginx/src/os/unix/ngx_linux_aio_read.c +137 -0
- data/src/nginx/src/os/unix/ngx_linux_config.h +117 -0
- data/src/nginx/src/os/unix/ngx_linux_init.c +91 -0
- data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +378 -0
- data/src/nginx/src/os/unix/ngx_os.h +84 -0
- data/src/nginx/src/os/unix/ngx_posix_config.h +153 -0
- data/src/nginx/src/os/unix/ngx_posix_init.c +124 -0
- data/src/nginx/src/os/unix/ngx_process.c +590 -0
- data/src/nginx/src/os/unix/ngx_process.h +87 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.c +1390 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.h +61 -0
- data/src/nginx/src/os/unix/ngx_pthread_thread.c +278 -0
- data/src/nginx/src/os/unix/ngx_readv_chain.c +258 -0
- data/src/nginx/src/os/unix/ngx_recv.c +180 -0
- data/src/nginx/src/os/unix/ngx_send.c +73 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.c +135 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.h +52 -0
- data/src/nginx/src/os/unix/ngx_shmem.c +126 -0
- data/src/nginx/src/os/unix/ngx_shmem.h +29 -0
- data/src/nginx/src/os/unix/ngx_socket.c +116 -0
- data/src/nginx/src/os/unix/ngx_socket.h +64 -0
- data/src/nginx/src/os/unix/ngx_solaris.h +16 -0
- data/src/nginx/src/os/unix/ngx_solaris_config.h +107 -0
- data/src/nginx/src/os/unix/ngx_solaris_init.c +75 -0
- data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +251 -0
- data/src/nginx/src/os/unix/ngx_sunpro_amd64.il +43 -0
- data/src/nginx/src/os/unix/ngx_sunpro_atomic_sparc64.h +61 -0
- data/src/nginx/src/os/unix/ngx_sunpro_sparc64.il +36 -0
- data/src/nginx/src/os/unix/ngx_sunpro_x86.il +44 -0
- data/src/nginx/src/os/unix/ngx_thread.h +128 -0
- data/src/nginx/src/os/unix/ngx_time.c +104 -0
- data/src/nginx/src/os/unix/ngx_time.h +66 -0
- data/src/nginx/src/os/unix/ngx_udp_recv.c +115 -0
- data/src/nginx/src/os/unix/ngx_user.c +109 -0
- data/src/nginx/src/os/unix/ngx_user.h +24 -0
- data/src/nginx/src/os/unix/ngx_writev_chain.c +181 -0
- data/src/nginx/src/os/unix/rfork_thread.S +73 -0
- metadata +419 -0
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.15.0
|
data/bin/nginxtra
ADDED
data/lib/nginxtra.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "nginxtra/action"
|
2
|
+
require "nginxtra/actions/compile"
|
3
|
+
require "nginxtra/actions/install"
|
4
|
+
require "nginxtra/actions/reload"
|
5
|
+
require "nginxtra/actions/restart"
|
6
|
+
require "nginxtra/actions/start"
|
7
|
+
require "nginxtra/actions/status"
|
8
|
+
require "nginxtra/actions/stop"
|
9
|
+
require "nginxtra/cli"
|
10
|
+
require "nginxtra/config"
|
11
|
+
require "nginxtra/error"
|
12
|
+
require "nginxtra/status"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
module Action
|
3
|
+
def initialize(thor, config)
|
4
|
+
@thor = thor
|
5
|
+
@config = config
|
6
|
+
end
|
7
|
+
|
8
|
+
# Run a daemon command to start or stop the nginx process.
|
9
|
+
def daemon(action, additional_options = nil)
|
10
|
+
action = "#{action} #{additional_options}" if additional_options
|
11
|
+
run! "#{sudo}start-stop-daemon --#{action} --quiet --pidfile #{Nginxtra::Config.nginx_pidfile} --exec #{Nginxtra::Config.nginx_executable}"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def run!(command)
|
16
|
+
@thor.run command
|
17
|
+
raise Nginxtra::Error::RunFailed.new("The last run command failed") unless $?.success?
|
18
|
+
end
|
19
|
+
|
20
|
+
def force?
|
21
|
+
@thor.options["force"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def interactive?
|
25
|
+
!non_interactive?
|
26
|
+
end
|
27
|
+
|
28
|
+
def non_interactive?
|
29
|
+
@thor.options["non-interactive"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def sudo(force = false)
|
33
|
+
"sudo " if (force || @config.require_root?) && Process.uid != 0
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
module Actions
|
3
|
+
# The Nginxtra::Actions::Compile class encapsulates compiling
|
4
|
+
# nginx so it is ready with the specified compile options. An
|
5
|
+
# optional option of :force can be passed with true to make
|
6
|
+
# compilation happen no matter what.
|
7
|
+
class Compile
|
8
|
+
include Nginxtra::Action
|
9
|
+
|
10
|
+
# Run the full compilation of nginx.
|
11
|
+
def compile
|
12
|
+
return up_to_date unless should_compile?
|
13
|
+
copy_to_base
|
14
|
+
configure
|
15
|
+
make
|
16
|
+
make "install"
|
17
|
+
update_last_compile
|
18
|
+
end
|
19
|
+
|
20
|
+
# Copy the nginx source directory to the base directory.
|
21
|
+
def copy_to_base
|
22
|
+
@thor.directory "src/nginx", Nginxtra::Config.src_dir
|
23
|
+
end
|
24
|
+
|
25
|
+
# Configure nginx with the specified compile options.
|
26
|
+
def configure
|
27
|
+
@thor.inside Nginxtra::Config.src_dir do
|
28
|
+
run! "sh configure --prefix=#{Nginxtra::Config.build_dir} --conf-path=#{Nginxtra::Config.nginx_config} --pid-path=#{Nginxtra::Config.nginx_pidfile} #{@config.compile_options}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Run make against the configured nginx.
|
33
|
+
def make(*args)
|
34
|
+
@thor.inside Nginxtra::Config.src_dir do
|
35
|
+
run! ["make", *args].join(" ")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Determine if compiling should happen. This will return false
|
40
|
+
# if the last compile options equal the current options, or if
|
41
|
+
# the force option was passed in at construction time.
|
42
|
+
def should_compile?
|
43
|
+
return true if force?
|
44
|
+
Nginxtra::Status[:last_compile_options] != @config.compile_options
|
45
|
+
end
|
46
|
+
|
47
|
+
# Update Nginxtra::Status with the last compile time and
|
48
|
+
# options.
|
49
|
+
def update_last_compile
|
50
|
+
Nginxtra::Status[:last_compile_options] = @config.compile_options
|
51
|
+
Nginxtra::Status[:last_compile_time] = Time.now
|
52
|
+
end
|
53
|
+
|
54
|
+
# Notify the user that the compilation is up to date
|
55
|
+
def up_to_date
|
56
|
+
@thor.say "nginx compilation is up to date"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
module Actions
|
3
|
+
# The Nginxtra::Actions::Install class encapsulates installing
|
4
|
+
# nginxtra so that nginx can be started and stopped automatically
|
5
|
+
# when the server is started or stopped.
|
6
|
+
class Install
|
7
|
+
include Nginxtra::Action
|
8
|
+
|
9
|
+
# Run the installation of nginxtra, but only after first
|
10
|
+
# prompting if the user wants the install. This will do nothing
|
11
|
+
# if run with --non-interactive mode.
|
12
|
+
def optional_install
|
13
|
+
return installation_skipped if non_interactive?
|
14
|
+
return up_to_date unless should_install?
|
15
|
+
return unless requesting_install?
|
16
|
+
install
|
17
|
+
end
|
18
|
+
|
19
|
+
# Run the installation of nginxtra.
|
20
|
+
def install
|
21
|
+
return up_to_date unless should_install?
|
22
|
+
create_etc_script
|
23
|
+
remember_config_location
|
24
|
+
update_last_install
|
25
|
+
end
|
26
|
+
|
27
|
+
# Create a script in the base directory which be symlinked to
|
28
|
+
# /etc/init.d/nginxtra and then used to start and stop nginxtra
|
29
|
+
# via update-rc.d.
|
30
|
+
def create_etc_script
|
31
|
+
filename = "etc.init.d.nginxtra"
|
32
|
+
|
33
|
+
@thor.inside Nginxtra::Config.base_dir do
|
34
|
+
@thor.create_file filename, %{#!/bin/sh
|
35
|
+
|
36
|
+
### BEGIN INIT INFO
|
37
|
+
# Provides: nginxtra
|
38
|
+
# Required-Start: $all
|
39
|
+
# Required-Stop: $all
|
40
|
+
# Default-Start: 2 3 4 5
|
41
|
+
# Default-Stop: 0 1 6
|
42
|
+
# Short-Description: starts nginxtra, which is a wrapper around the nginx web server
|
43
|
+
# Description: starts nginxtra which starts nginx using start-stop-daemon
|
44
|
+
### END INIT INFO
|
45
|
+
|
46
|
+
export GEM_HOME="#{ENV["GEM_HOME"]}"
|
47
|
+
export GEM_PATH="#{ENV["GEM_PATH"]}"
|
48
|
+
#{Nginxtra::Config.ruby_path} "#{File.join Nginxtra::Config.gem_dir, "bin/nginxtra"}" "$1" --basedir="#{Nginxtra::Config.base_dir}" --config="#{Nginxtra::Config.loaded_config_path}" --non-interactive
|
49
|
+
}, :force => true
|
50
|
+
@thor.chmod filename, 0755
|
51
|
+
end
|
52
|
+
|
53
|
+
run! %{#{sudo true}rm /etc/init.d/nginxtra && #{sudo true}ln -s "#{File.join Nginxtra::Config.base_dir, filename}" /etc/init.d/nginxtra}
|
54
|
+
run! %{#{sudo true}update-rc.d nginxtra defaults}
|
55
|
+
end
|
56
|
+
|
57
|
+
# Notify the user that installation should be up to date.
|
58
|
+
def up_to_date
|
59
|
+
@thor.say "nginxtra installation is up to date"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Notify to the user that installation is being skipped.
|
63
|
+
def installation_skipped
|
64
|
+
@thor.say "skipping nginxtra installation"
|
65
|
+
end
|
66
|
+
|
67
|
+
# Remember the last config location, and use it unless the
|
68
|
+
# config is explicitly passed in.
|
69
|
+
def remember_config_location
|
70
|
+
# Absolute path somehow turns the path to a binary string when
|
71
|
+
# output to Yaml... so make it a string so it stays ascii
|
72
|
+
# readable.
|
73
|
+
Nginxtra::Status[:remembered_config] = Nginxtra::Config.loaded_config_path.to_s
|
74
|
+
end
|
75
|
+
|
76
|
+
# Mark the last installed version and last installed time (the
|
77
|
+
# former being used to determine if nginxtra has been installed
|
78
|
+
# yet).
|
79
|
+
def update_last_install
|
80
|
+
Nginxtra::Status[:last_install_version] = Nginxtra::Config.version
|
81
|
+
Nginxtra::Status[:last_install_time] = Time.now
|
82
|
+
end
|
83
|
+
|
84
|
+
# Ask the user if they wish to install. Return whether the user
|
85
|
+
# requests the install.
|
86
|
+
def requesting_install?
|
87
|
+
@thor.yes? "Would you like to install nginxtra?"
|
88
|
+
end
|
89
|
+
|
90
|
+
# Determine if the install should proceed. This will be true if
|
91
|
+
# the force option was used, or if this version of nginxtra
|
92
|
+
# differs from the last version installed.
|
93
|
+
def should_install?
|
94
|
+
return true if force?
|
95
|
+
Nginxtra::Status[:last_install_version] != Nginxtra::Config.version
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
module Actions
|
3
|
+
# The Nginxtra::Actions::Reload class encapsulates reloading nginx.
|
4
|
+
class Reload
|
5
|
+
include Nginxtra::Action
|
6
|
+
|
7
|
+
# Reload nginx.
|
8
|
+
def reload
|
9
|
+
daemon :stop, "--signal HUP"
|
10
|
+
Nginxtra::Status[:last_reload_time] = Time.now
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
module Actions
|
3
|
+
# The Nginxtra::Actions::Restart class encapsulates restarting nginx.
|
4
|
+
class Restart
|
5
|
+
include Nginxtra::Action
|
6
|
+
|
7
|
+
# Restart nginx by stopping and starting.
|
8
|
+
def restart
|
9
|
+
Nginxtra::Actions::Stop.new(@thor, @config).stop
|
10
|
+
sleep 1
|
11
|
+
Nginxtra::Actions::Start.new(@thor, @config).start
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
module Actions
|
3
|
+
# The Nginxtra::Actions::Compile class encapsulates starting nginx
|
4
|
+
# with the specified configuration file. It also makes sure that
|
5
|
+
# nginx has been compiled with the correct options.
|
6
|
+
class Start
|
7
|
+
include Nginxtra::Action
|
8
|
+
|
9
|
+
# First, ensure nginx has been compiled, then make sure
|
10
|
+
# configuration is correct, and finally start nginx and note the
|
11
|
+
# start time.
|
12
|
+
def start
|
13
|
+
compile
|
14
|
+
install
|
15
|
+
save_config_files
|
16
|
+
start_nginx
|
17
|
+
update_last_start
|
18
|
+
end
|
19
|
+
|
20
|
+
# Invoke nginx compilation, to ensure it is up to date.
|
21
|
+
def compile
|
22
|
+
Nginxtra::Actions::Compile.new(@thor, @config).compile
|
23
|
+
end
|
24
|
+
|
25
|
+
# Invoke nginxtra installation, but only if the user allows it.
|
26
|
+
def install
|
27
|
+
Nginxtra::Actions::Install.new(@thor, @config).optional_install
|
28
|
+
end
|
29
|
+
|
30
|
+
# Save nginx config files to the proper config file path.
|
31
|
+
def save_config_files
|
32
|
+
files = @config.files
|
33
|
+
raise Nginxtra::Error::InvalidConfig.new("Missing definition for nginx.conf") unless files.include? "nginx.conf"
|
34
|
+
|
35
|
+
@thor.inside Nginxtra::Config.config_dir do
|
36
|
+
files.each do |filename|
|
37
|
+
@thor.create_file filename, @config.file_contents(filename), :force => true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Start nginx as a daemon.
|
43
|
+
def start_nginx
|
44
|
+
daemon :start
|
45
|
+
end
|
46
|
+
|
47
|
+
# Update the last nginx start time.
|
48
|
+
def update_last_start
|
49
|
+
Nginxtra::Status[:last_start_time] = Time.now
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
module Actions
|
3
|
+
# The Nginxtra::Actions::Status class encapsulates checking on the
|
4
|
+
# status of nginx (whether or not it is running based on the pid
|
5
|
+
# file).
|
6
|
+
class Status
|
7
|
+
include Nginxtra::Action
|
8
|
+
|
9
|
+
def status
|
10
|
+
@thor.say "The nginx server status: #{colored_message}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def colored_message
|
14
|
+
if running?
|
15
|
+
@thor.set_color "running", :green, true
|
16
|
+
else
|
17
|
+
@thor.set_color "stopped", :red, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def running?
|
22
|
+
return false unless File.exists? Nginxtra::Config.nginx_pidfile
|
23
|
+
pid = File.read(Nginxtra::Config.nginx_pidfile).strip
|
24
|
+
Process.getpgid pid.to_i
|
25
|
+
true
|
26
|
+
rescue Errno::ESRCH
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
module Actions
|
3
|
+
# The Nginxtra::Actions::Stop class encapsulates stopping nginx.
|
4
|
+
class Stop
|
5
|
+
include Nginxtra::Action
|
6
|
+
|
7
|
+
# Stop nginx and note the new last stop time.
|
8
|
+
def stop
|
9
|
+
daemon :stop
|
10
|
+
Nginxtra::Status[:last_stop_time] = Time.now
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/nginxtra/cli.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Nginxtra
|
4
|
+
class CLI < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
class_option "force", :type => :boolean, :banner => "Force a task to happen, regardless of what nginxtra thinks", :aliases => "-f"
|
8
|
+
class_option "non-interactive", :type => :boolean, :banner => "If nginxtra would ask a question, it instead proceeds as if 'no' were the answer", :aliases => "-I"
|
9
|
+
class_option "config", :type => :string, :banner => "Specify the configuration file to use", :aliases => "-c"
|
10
|
+
class_option "basedir", :type => :string, :banner => "Specify the directory to store nginx files", :aliases => "-b"
|
11
|
+
|
12
|
+
desc "compile", "Compiles nginx based on nginxtra.conf.rb"
|
13
|
+
long_desc "
|
14
|
+
Compile nginx with the compilation options specified in nginxtra.conf.rb. If it
|
15
|
+
has already been compiled with those options, compilation will be skipped. Note
|
16
|
+
that start will already run compilation, so compilation is not really needed to
|
17
|
+
be executed directly. However, you can force recompilation by running this task
|
18
|
+
with the --force option."
|
19
|
+
def compile
|
20
|
+
Nginxtra::Actions::Compile.new(self, prepare_config!).compile
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "install", "Installs nginxtra"
|
24
|
+
long_desc "
|
25
|
+
Install nginxtra so nginx will start at system startup time, and stop when the
|
26
|
+
system is shut down. Before installing, it will be checked if it had been
|
27
|
+
already installed with this version of nginxtra. If it was already installed,
|
28
|
+
installation will be skipped unless the --force option is given."
|
29
|
+
def install
|
30
|
+
Nginxtra::Actions::Install.new(self, prepare_config!).install
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "start", "Start nginx with configuration defined in nginxtra.conf.rb"
|
34
|
+
long_desc "
|
35
|
+
Start nginx based on nginxtra.conf.rb. If nginx has not yet been compiled, it
|
36
|
+
will be compiled. The configuration for nginx will automatically be handled by
|
37
|
+
nginxtra so it matches what is defined in nginxtra.conf.rb."
|
38
|
+
def start
|
39
|
+
Nginxtra::Actions::Start.new(self, prepare_config!).start
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "stop", "Stop nginx"
|
43
|
+
def stop
|
44
|
+
Nginxtra::Actions::Stop.new(self, prepare_config!).stop
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "restart", "Restart nginx"
|
48
|
+
def restart
|
49
|
+
Nginxtra::Actions::Restart.new(self, prepare_config!).restart
|
50
|
+
end
|
51
|
+
map "force-reload" => "restart"
|
52
|
+
|
53
|
+
desc "reload", "Reload nginx"
|
54
|
+
def reload
|
55
|
+
Nginxtra::Actions::Reload.new(self, prepare_config!).reload
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "status", "Check if nginx is running"
|
59
|
+
def status
|
60
|
+
Nginxtra::Actions::Status.new(self, prepare_config!).status
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
def prepare_config!
|
65
|
+
Nginxtra::Config.base_dir = options["basedir"]
|
66
|
+
result = Nginxtra::Config.require! options["config"]
|
67
|
+
say "Using config #{Nginxtra::Config.loaded_config_path}"
|
68
|
+
result
|
69
|
+
end
|
70
|
+
|
71
|
+
class << self
|
72
|
+
def source_root
|
73
|
+
File.absolute_path File.expand_path("../../..", __FILE__)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,339 @@
|
|
1
|
+
module Nginxtra
|
2
|
+
# The Nginxtra::Config class is the central class for configuring
|
3
|
+
# nginxtra. It provides the DSL for defining the compilation
|
4
|
+
# options of nginx and the config file contents.
|
5
|
+
class Config
|
6
|
+
FILENAME = "nginxtra.conf.rb".freeze
|
7
|
+
NGINX_CONF_FILENAME = "nginx.conf".freeze
|
8
|
+
NGINX_PIDFILE_FILENAME = ".nginx_pid".freeze
|
9
|
+
@@last_config = nil
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@requires_root = false
|
13
|
+
@compile_options = []
|
14
|
+
@files = {}
|
15
|
+
@@last_config = self
|
16
|
+
end
|
17
|
+
|
18
|
+
# This method is used to configure nginx via nginxtra. Inside
|
19
|
+
# your nginxtra.conf.rb config file, you should use it like:
|
20
|
+
# nginxtra.config do
|
21
|
+
# ...
|
22
|
+
# end
|
23
|
+
def config(&block)
|
24
|
+
instance_eval &block
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
# Notify nginxtra that root access is needed to run the daemon
|
29
|
+
# commands. Sudo will automatically be used if the current user
|
30
|
+
# isn't root.
|
31
|
+
def require_root!
|
32
|
+
@requires_root = true
|
33
|
+
end
|
34
|
+
|
35
|
+
# Retrieve whether root is required to run the daemon. This will
|
36
|
+
# return true only if require_root! was invoked from the config
|
37
|
+
# file.
|
38
|
+
def require_root?
|
39
|
+
@requires_root
|
40
|
+
end
|
41
|
+
|
42
|
+
# Require passenger. This will include http_ssl_module,
|
43
|
+
# http_gzip_static_module, add a Wno-error compilation option, and
|
44
|
+
# add the passenger module to the proper passenger path.
|
45
|
+
def require_passenger!
|
46
|
+
compile_option %{--with-http_ssl_module}
|
47
|
+
compile_option %{--with-http_gzip_static_module}
|
48
|
+
compile_option %{--with-cc-opt=-Wno-error}
|
49
|
+
compile_option %{--add-module="#{File.join Nginxtra::Config.passenger_spec.gem_dir, "ext/nginx"}"}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Obtain the compile options that have been configured.
|
53
|
+
def compile_options
|
54
|
+
@compile_options.join " "
|
55
|
+
end
|
56
|
+
|
57
|
+
# Specify a compile time option for nginx. The leading "--" is
|
58
|
+
# optional and will be added if missing. The following options
|
59
|
+
# are not allowed and will cause an exception: --prefix,
|
60
|
+
# --sbin-path, --conf-path and --pid-path. The order the options
|
61
|
+
# are specified will be the order they are used when configuring
|
62
|
+
# nginx.
|
63
|
+
#
|
64
|
+
# Example usage:
|
65
|
+
# nginxtra.config do
|
66
|
+
# compile_option "--with-http_gzip_static_module"
|
67
|
+
# compile_option "--with-cc-opt=-Wno-error"
|
68
|
+
# end
|
69
|
+
def compile_option(opt)
|
70
|
+
opt = "--#{opt}" unless opt =~ /^--/
|
71
|
+
raise Nginxtra::Error::InvalidConfig.new("The --prefix compile option is not allowed with nginxtra. It is reserved so nginxtra can control where nginx is compiled and run from.") if opt =~ /--prefix=/
|
72
|
+
raise Nginxtra::Error::InvalidConfig.new("The --sbin-path compile option is not allowed with nginxtra. It is reserved so nginxtra can control what binary is used to run nginx.") if opt =~ /--sbin-path=/
|
73
|
+
raise Nginxtra::Error::InvalidConfig.new("The --conf-path compile option is not allowed with nginxtra. It is reserved so nginxtra can control the configuration entirely via #{Nginxtra::Config::FILENAME}.") if opt =~ /--conf-path=/
|
74
|
+
raise Nginxtra::Error::InvalidConfig.new("The --pid-path compile option is not allowed with nginxtra. It is reserved so nginxtra can control where the pid file is created.") if opt =~ /--pid-path=/
|
75
|
+
@compile_options << opt
|
76
|
+
end
|
77
|
+
|
78
|
+
# Obtain the config file contents that will be used for
|
79
|
+
# nginx.conf.
|
80
|
+
def file_contents(filename)
|
81
|
+
@files[filename].config_file_contents
|
82
|
+
end
|
83
|
+
|
84
|
+
# Define a new config file with the given filename and the block
|
85
|
+
# to define it with.
|
86
|
+
def file(filename, &block)
|
87
|
+
@files[filename] = Nginxtra::Config::ConfigFile.new(&block)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Retrieve the files that have been defined.
|
91
|
+
def files
|
92
|
+
@files.keys
|
93
|
+
end
|
94
|
+
|
95
|
+
class << self
|
96
|
+
# Obtain the last Nginxtra::Config object that was created.
|
97
|
+
def last_config
|
98
|
+
@@last_config
|
99
|
+
end
|
100
|
+
|
101
|
+
# Obtain the config file path based on the current directory.
|
102
|
+
# This will be the path to the first nginxtra.conf.rb found
|
103
|
+
# starting at the current directory and working up until it is
|
104
|
+
# found or the filesystem boundary is hit (so /nginxtra.conf.rb
|
105
|
+
# is the last possible tested file). If none is found, nil is
|
106
|
+
# returned.
|
107
|
+
def path
|
108
|
+
path = File.absolute_path "."
|
109
|
+
|
110
|
+
begin
|
111
|
+
config = File.join path, FILENAME
|
112
|
+
return config if File.exists? config
|
113
|
+
path = File.dirname path
|
114
|
+
end until path == "/"
|
115
|
+
|
116
|
+
config = File.join path, FILENAME
|
117
|
+
config if File.exists? config
|
118
|
+
end
|
119
|
+
|
120
|
+
# Retrieve the path to the config file that was loaded.
|
121
|
+
def loaded_config_path
|
122
|
+
@loaded_config_path
|
123
|
+
end
|
124
|
+
|
125
|
+
# Determine where the config file is and require it. Return the
|
126
|
+
# resulting config loaded by the path.
|
127
|
+
# Nginxtra::Error::MissingConfig will be raised if the config
|
128
|
+
# file cannot be found.
|
129
|
+
def require!(config_path = nil)
|
130
|
+
if config_path
|
131
|
+
config_path = File.absolute_path config_path
|
132
|
+
elsif Nginxtra::Status[:remembered_config]
|
133
|
+
config_path = File.absolute_path Nginxtra::Status[:remembered_config]
|
134
|
+
else
|
135
|
+
config_path = path
|
136
|
+
end
|
137
|
+
|
138
|
+
raise Nginxtra::Error::MissingConfig.new("Cannot find #{FILENAME} to configure nginxtra!") unless config_path
|
139
|
+
raise Nginxtra::Error::MissingConfig.new("Missing file #{config_path} to configure nginxtra!") unless File.exists?(config_path)
|
140
|
+
require config_path
|
141
|
+
raise Nginxtra::Error::InvalidConfig.new("No configuration is specified in #{config_path}!") unless last_config
|
142
|
+
@loaded_config_path = config_path
|
143
|
+
last_config
|
144
|
+
end
|
145
|
+
|
146
|
+
# The path to the VERSION file in the gem.
|
147
|
+
def version_file
|
148
|
+
File.join gem_dir, "VERSION"
|
149
|
+
end
|
150
|
+
|
151
|
+
# The current version of nginxtra.
|
152
|
+
def version
|
153
|
+
@version ||= File.read(version_file).strip
|
154
|
+
end
|
155
|
+
|
156
|
+
# The corresponding nginx version (based on the nginxtra
|
157
|
+
# version).
|
158
|
+
def nginx_version
|
159
|
+
@nginx_version ||= version.split(".").take(3).join(".")
|
160
|
+
end
|
161
|
+
|
162
|
+
# Retrieve the base dir of nginxtra (located just above lib,
|
163
|
+
# probably in your gems/nginxtra-xxx directory).
|
164
|
+
def gem_dir
|
165
|
+
File.absolute_path File.expand_path("../../..", __FILE__)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Set the base directory (retrieved from base_dir). If this is
|
169
|
+
# not called, it will default to the ~/.nginxtra directory.
|
170
|
+
# This will do nothing if the value is nil.
|
171
|
+
def base_dir=(value)
|
172
|
+
@base_dir = value if value
|
173
|
+
end
|
174
|
+
|
175
|
+
# Retrieve the base dir of nginxtra stored files (located in
|
176
|
+
# ~/.nginxtra, unless overridden via the --basedir option).
|
177
|
+
def base_dir
|
178
|
+
@base_dir ||= File.absolute_path File.expand_path("~/.nginxtra")
|
179
|
+
end
|
180
|
+
|
181
|
+
# The base nginx dir versioned to the current version inside the
|
182
|
+
# base dir.
|
183
|
+
def base_nginx_dir
|
184
|
+
File.join base_dir, "nginx-#{nginx_version}"
|
185
|
+
end
|
186
|
+
|
187
|
+
# Retrieve the directory where nginx source is located.
|
188
|
+
def src_dir
|
189
|
+
File.join base_nginx_dir, "src"
|
190
|
+
end
|
191
|
+
|
192
|
+
# Retrieve the directory where nginx is built into.
|
193
|
+
def build_dir
|
194
|
+
File.join base_nginx_dir, "build"
|
195
|
+
end
|
196
|
+
|
197
|
+
# The path to the config directory where nginx config files are
|
198
|
+
# stored (including nginx.conf).
|
199
|
+
def config_dir
|
200
|
+
File.join base_dir, "conf"
|
201
|
+
end
|
202
|
+
|
203
|
+
# The full path to the nginx.conf file that is fed to nginx,
|
204
|
+
# based on nginxtra.conf.rb.
|
205
|
+
def nginx_config
|
206
|
+
File.join config_dir, NGINX_CONF_FILENAME
|
207
|
+
end
|
208
|
+
|
209
|
+
# The full path to the nginx pidfile that is used for running
|
210
|
+
# nginx.
|
211
|
+
def nginx_pidfile
|
212
|
+
File.join base_dir, NGINX_PIDFILE_FILENAME
|
213
|
+
end
|
214
|
+
|
215
|
+
# Retrieve the full path to the nginx executable.
|
216
|
+
def nginx_executable
|
217
|
+
File.join build_dir, "sbin/nginx"
|
218
|
+
end
|
219
|
+
|
220
|
+
# Retrieve the path to ruby.
|
221
|
+
def ruby_path
|
222
|
+
`which ruby`.strip
|
223
|
+
end
|
224
|
+
|
225
|
+
# Cache and retrieve the gemspec for passenger, if it exists.
|
226
|
+
# An InvalidConfig exception will be raised if passenger cannot
|
227
|
+
# be found.
|
228
|
+
def passenger_spec
|
229
|
+
@passenger_spec ||= Gem::Specification.find_by_name("passenger").tap do |spec|
|
230
|
+
raise InvalidConfig.new("You cannot reference passenger unless the passenger gem is installed!") if spec.nil?
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
# Represents a config file being defined by nginxtra.conf.rb.
|
236
|
+
class ConfigFile
|
237
|
+
def initialize(&block)
|
238
|
+
@file_contents = []
|
239
|
+
instance_eval &block
|
240
|
+
end
|
241
|
+
|
242
|
+
# The file contents that were defined for this config file.
|
243
|
+
def config_file_contents
|
244
|
+
@file_contents.join "\n"
|
245
|
+
end
|
246
|
+
|
247
|
+
# Add a new line to the config. A semicolon is added
|
248
|
+
# automatically.
|
249
|
+
#
|
250
|
+
# Example usage:
|
251
|
+
# nginxtra.config do
|
252
|
+
# config_line "user my_user"
|
253
|
+
# config_line "worker_processes 42"
|
254
|
+
# end
|
255
|
+
def config_line(contents)
|
256
|
+
@file_contents << "#{contents};"
|
257
|
+
end
|
258
|
+
|
259
|
+
# Add a new line to the config, but without a semicolon at the
|
260
|
+
# end.
|
261
|
+
#
|
262
|
+
# Example usage:
|
263
|
+
# nginxtra.config do
|
264
|
+
# bare_config_line "a line with no semicolon"
|
265
|
+
# end
|
266
|
+
def bare_config_line(contents)
|
267
|
+
@file_contents << contents
|
268
|
+
end
|
269
|
+
|
270
|
+
# Add a new block to the config. This will result in outputting
|
271
|
+
# something in the config like a server block, wrapped in { }. A
|
272
|
+
# block should be passed in to this method, which will represent
|
273
|
+
# the contents of the block (if no block is given, the resulting
|
274
|
+
# config will have an empty block).
|
275
|
+
#
|
276
|
+
# Example usage:
|
277
|
+
# nginxtra.config do
|
278
|
+
# config_block "events" do
|
279
|
+
# config_line "worker_connections 512"
|
280
|
+
# end
|
281
|
+
# end
|
282
|
+
def config_block(name)
|
283
|
+
@file_contents << "#{name} {"
|
284
|
+
yield if block_given?
|
285
|
+
@file_contents << "}"
|
286
|
+
end
|
287
|
+
|
288
|
+
# Arbitrary config can be specified as long as the name doesn't
|
289
|
+
# clash with one of the Config instance methods.
|
290
|
+
#
|
291
|
+
# Example usage:
|
292
|
+
# nginxtra.config do
|
293
|
+
# user "my_user"
|
294
|
+
# worker_processes 42
|
295
|
+
# events do
|
296
|
+
# worker_connections 512
|
297
|
+
# end
|
298
|
+
# end
|
299
|
+
#
|
300
|
+
# Any arguments the the method will be joined with the method name
|
301
|
+
# with a space to produce the output.
|
302
|
+
def method_missing(method, *args, &block)
|
303
|
+
values = [method, *args].join " "
|
304
|
+
|
305
|
+
if block
|
306
|
+
config_block values, &block
|
307
|
+
else
|
308
|
+
config_line values
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
# Output the passenger_root line, including the proper passenger
|
313
|
+
# gem path.
|
314
|
+
def passenger_root!
|
315
|
+
config_line %{passenger_root #{Nginxtra::Config.passenger_spec.gem_dir}}
|
316
|
+
end
|
317
|
+
|
318
|
+
# Output the passenger_ruby, including the proper ruby path.
|
319
|
+
def passenger_ruby!
|
320
|
+
config_line %{passenger_ruby #{Nginxtra::Config.ruby_path}}
|
321
|
+
end
|
322
|
+
|
323
|
+
# Output that passenger is enabled in this block.
|
324
|
+
def passenger_on!
|
325
|
+
config_line %{passenger_enabled on}
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
# This is an alias for constructing a new Nginxtra::Config object. It
|
332
|
+
# is used for readability of the nginxtra.conf.rb config file.
|
333
|
+
# Example usage:
|
334
|
+
# nginxtra.config do
|
335
|
+
# ...
|
336
|
+
# end
|
337
|
+
def nginxtra
|
338
|
+
Nginxtra::Config.new
|
339
|
+
end
|