installer/unix-like/create_texts.rb in rhoconnect-3.3.5 vs installer/unix-like/create_texts.rb in rhoconnect-3.3.6

- old
+ new

@@ -323,11 +323,11 @@ size 100k delaycompress sharedscripts postrotate test ! -f /opt/nginx/logs/nginx.pid || kill -USR1 `cat /opt/nginx/logs/nginx.pid` - endscript + endscript } _NGINX_LOGRORATE_CONF_ File.open('/etc/logrotate.d/nginx', 'w') { |f| f << nginx_logrorate_conf } end @@ -346,12 +346,19 @@ http { include mime.types; default_type application/octet-stream; + log_format time_combined '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for" "$request_time"'; + access_log logs/access.log time_combined; + sendfile on; - keepalive_timeout 65; + keepalive_timeout 120; + client_max_body_size 4m; + client_body_buffer_size 128k; #gzip on; include /opt/nginx/conf/conf.d/*.conf; } _NGINX_CONF_ @@ -371,19 +378,22 @@ File.open('/opt/nginx/conf/nginx.conf', 'w' ) { |f| f << nginx_server_conf } Dir.mkdir "/opt/nginx/conf/conf.d" unless File.exist? "/opt/nginx/conf/conf.d" rho_vhost_conf = <<_VHOST_CONF_ upstream thin_cluster { - ip_hash; + least_conn; server unix:/tmp/thin.0.sock; server unix:/tmp/thin.1.sock; -# server unix:/tmp/thin.2.sock; -# server unix:/tmp/thin.3.sock; + # Add additional copies if need more Thin servers + #server unix:/tmp/thin.2.sock; + #server unix:/tmp/thin.3.sock; } server { - listen 80; + listen 80; # listen for ipv4 + # listen [::]:80 default ipv6only=on; # listen for ipv6 + root /opt/nginx/html/#{app_name}/public; # <-- be sure to point to 'public' folder of your application! # access_log off; # <-- disable access logging # error_log /dev/null crit; # <-- disable error logging, but critical errors only location / { @@ -397,10 +407,19 @@ error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } + + # Uncomment the following location to get some status from nginx + # location /nginx_status { + # stub_status on; + # access_log off; + # allow 127.0.0.1; + # allow SOME.IP.ADD.RESS; + # deny all; + # } } _VHOST_CONF_ File.open('/opt/nginx/conf/conf.d/rhoconnect.conf', 'w' ) { |f| f << rho_vhost_conf } end @@ -522,12 +541,13 @@ # ... or as root user generate a new one $ env PATH=/opt/rhoconnect/bin:$PATH thin config -C /etc/thin/your_rhoconnect_app.yml \ -c /opt/nginx/html/your_rhoconnect_app/ \ - --socket /tmp/thin.sock --servers 2 --log /opt/nginx/logs/thin.log \ - --pid /var/run/thin.pid -e production + --socket /tmp/thin.sock --servers 2 \ + --user nginx --group nginx \ + --log /var/log/thin/thin.log --pid /var/run/thin/thin.pid -e production` f) As root user restart Nginx, and Thin servers /etc/init.d/nginx restart /etc/init.d/thin restart @@ -548,31 +568,12 @@ raise "Generatiion of rhoconnect application failured:\n#{log}" if $? != 0 Dir.chdir "../" `chown -R nginx:nginx rhoapp/` end -def copy_benchapp(rho_path) - puts "Copy bench rhoconnect application to /opt/nginx/html directory ..." - Dir.chdir "#{rho_path}/installer" - `tar xzf bench.tar.gz -C #{rho_path}` - `rm -rf bench.tar.gz` - - `#{rho_path}/bin/gem install ffaker --no-ri --no-rdoc` - `#{rho_path}/bin/gem install thor --no-ri --no-rdoc` - - Dir.chdir "#{rho_path}/bench" - `cp -r benchapp /opt/nginx/html` - Dir.chdir "/opt/nginx/html/benchapp" - `rm -rf Gemfile.lock` - `#{rho_path}/bin/bundle install --without=test development` - Dir.chdir "../" - `chown -R nginx:nginx benchapp/` -end - def config_and_install_thin_scripts(rho_path) puts "Configuring and installing thin scripts ..." - #`env PATH=#{rho_path}/bin:$PATH thin install` thin_script = <<'_THIN_INIT_' #!/bin/sh ### BEGIN INIT INFO # Provides: thin # Required-Start: $local_fs $remote_fs @@ -611,18 +612,49 @@ ;; esac : _THIN_INIT_ + thin_init_script="/etc/init.d/thin" File.open(thin_init_script, 'w') { |f| f << thin_script } `chmod +x #{thin_init_script}` Dir.mkdir "/etc/thin" unless File.exist? "/etc/thin" - `env PATH=#{rho_path}/bin:$PATH thin config -C /etc/thin/rhoapp.yml -c /opt/nginx/html/rhoapp/ --socket /tmp/thin.sock --servers 2 --log /opt/nginx/logs/thin.log --pid /var/run/thin.pid -e production` + Dir.mkdir "/var/run/thin" unless File.exist? "/var/run/thin" + `chown nginx:nginx /var/run/thin` + + `env PATH=#{rho_path}/bin:$PATH \ + thin config -C /etc/thin/rhoapp.yml -c /opt/nginx/html/rhoapp/ \ + --socket /tmp/thin.sock --servers 2 \ + --user nginx --group nginx \ + --log /var/log/thin/thin.log --pid /var/run/thin/thin.pid -e production` + raise "Thin failed to configure rhoconnect application" if $? != 0 end +def config_thin_logrotate + Dir.mkdir "/var/log/thin" unless File.exist? "/var/log/thin" + `chown nginx:nginx /var/log/thin` + + thin_logrorate_conf = <<'_THIN_LOGRORATE_CONF_' +/var/log/thin/*.log { + daily + missingok + rotate 4 + compress + delaycompress + notifempty +# create 640 root adm + sharedscripts + postrotate + /etc/init.d/thin restart >/dev/null + endscript +} +_THIN_LOGRORATE_CONF_ + File.open('/etc/logrotate.d/thin', 'w') { |f| f << thin_logrorate_conf } +end + def create_texts if @redis create_redis_init create_redis_logrotate end @@ -633,10 +665,12 @@ create_nginx_conf_files "rhoapp" generate_rhoapp @prefix config_and_install_thin_scripts(@prefix) + config_thin_logrotate + distro_info = nginx_readme end common_info = generate_common_info readme = common_info + distro_info @@ -683,6 +717,13 @@ puts afterwords File.open("#{@log_file}", 'a') { |f| f << afterwords } if @log_file end -create_texts +begin + create_texts +rescue => ex + File.open("#{@log_file}", 'a') { |f| f << ex.message } if @log_file + puts + puts "#{ex.message}" + exit(1) +end \ No newline at end of file