installer/unix-like/create_texts.rb in rhoconnect-3.2.0.beta3 vs installer/unix-like/create_texts.rb in rhoconnect-3.2.0.beta4

- old
+ new

@@ -497,19 +497,20 @@ readme end def generate_rhoapp(rho_path) puts "Generating rhoconnect application: /opt/nginx/html/rhoapp ..." + Dir.chdir "/opt/nginx/html" - unless File.directory? "/opt/nginx/html/rhoapp" - `#{rho_path}/bin/rhoconnect app rhoapp` - Dir.chdir "rhoapp" - log = `#{rho_path}/bin/bundle install --without=test development` - raise "Generatiion of rhoconnect application failured:\n#{log}" if $? != 0 - Dir.chdir "../" - `chown -R nginx:nginx rhoapp/` - end + `rm -rf rhoapp` if File.directory? "/opt/nginx/html/rhoapp" + + `#{rho_path}/bin/rhoconnect app rhoapp` + Dir.chdir "rhoapp" + log = `#{rho_path}/bin/bundle install --without=test development 2>&1` + 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" @@ -528,31 +529,59 @@ `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` - # >> Installing thin service at /etc/rc.d/thin (RedHat) or /etc/init.d/thin (Ubuntu) ... + #`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 +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: S 0 1 6 +# Short-Description: thin initscript +# Description: thin +### END INIT INFO - thin_conf_file = (File.exists?('/etc/init.d/thin')) ? "/etc/init.d/thin" : "/etc/rc.d/thin" - File.open("/tmp/thin", 'w') do |f| - File.foreach(thin_conf_file) do |line| - if line =~ /^DAEMON/ - f << "export PATH=/opt/rhoconnect/bin:$PATH" << "\n" - f << "DAEMON=\"bundle exec thin\"" << "\n" - elsif line =~ /[ -x "$DAEMON" ] || exit 0/ - # do nothing - else - f << line - end - end - end - File.rename("/tmp/thin", thin_conf_file) - `chmod +x #{thin_conf_file}` +# Original author: Forrest Robertson +# Do NOT "set -e" + +export PATH=/opt/rhoconnect/bin:$PATH +DAEMON=/opt/rhoconnect/bin/thin +SCRIPT_NAME=/etc/init.d/thin +CONFIG_PATH=/etc/thin + +# Exit if the package is not installed +#[ -x "$DAEMON" ] || exit 0 + +case "$1" in + start) + $DAEMON start --all $CONFIG_PATH + ;; + stop) + $DAEMON stop --all $CONFIG_PATH + ;; + restart) + $DAEMON restart --all $CONFIG_PATH + ;; + *) + echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2 + exit 3 + ;; +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` - `ln -s /etc/rc.d/thin /etc/init.d/.` if File.directory?('/etc/rc.d') + raise "Thin failed to configure rhoconnect application" if $? != 0 end def create_texts if @redis create_redis_init @@ -561,18 +590,13 @@ if @server == 'nginx' create_nginx_init create_nginx_logrotate - @use_bench_app = File.exist? "#{@prefix}/installer/bench.tar.gz" - if @use_bench_app - create_nginx_conf_files "benchapp" - copy_benchapp @prefix - else - create_nginx_conf_files "rhoapp" - generate_rhoapp @prefix - end + create_nginx_conf_files "rhoapp" + generate_rhoapp @prefix + config_and_install_thin_scripts(@prefix) distro_info = nginx_readme end common_info = generate_common_info @@ -608,17 +632,24 @@ A) As root user start redis, nginx and thin servers: /etc/init.d/redis start /etc/init.d/nginx start /etc/init.d/thin start B) Open RhoConnect application web console in your browser: - http://server_ip_address + http://servername _NGINX_TO_DO_ end afterwords << about_app afterwords << "For more details see #{@prefix}/README file." puts afterwords File.open("#{@log_file}", 'a') { |f| f << afterwords } if @log_file + +ensure + if File.directory? "#{@prefix}/installer" + Dir.chdir "#{@prefix}/installer" + `rm -rf bin/ commands/ installer/ pkg/ tasks/ .bundle/ unix-like/` + `rm -f Rakefile` + end end create_texts