installer/unix-like/create_texts.rb in rhoconnect-3.0.5 vs installer/unix-like/create_texts.rb in rhoconnect-3.0.6
- old
+ new
@@ -164,21 +164,37 @@
echo -e "redis server stopped."
exit 0
}
redis_usage() {
- echo -e "Usage: $0 {start,stop}"
+ echo -e "Usage: $0 {start,stop,restart,status}"
exit 1
}
+redis_status() {
+ "$redis_cli" -p ${port} INFO > /dev/null 2>&1
+ info=$?
+ if (( $info )) ; then
+ echo "Redis server not running";
+ else
+ echo "Redis server running";
+ fi
+ exit $info
+}
+
#
# CLI logic.
#
case "$1" in
- start) redis_start ;;
- stop) redis_stop ;;
- *) redis_usage ;;
+ start) redis_start ;;
+ stop) redis_stop ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ status) redis_status ;;
+ *) redis_usage ;;
esac
_REDIS_INIT_SCRIPT_
redisInit="/etc/init.d/redis"
File.open(redisInit, 'w') { |f| f << redis_init_script }
@@ -308,11 +324,11 @@
_NGINX_LOGRORATE_CONF_
File.open('/etc/logrotate.d/nginx', 'w') { |f| f << nginx_logrorate_conf }
end
-def create_nginx_conf_files
+def create_nginx_conf_files(app_name)
nginx_server_conf = <<'_NGINX_CONF_'
user nginx;
worker_processes 4;
@@ -348,16 +364,17 @@
FileUtils.mv("/opt/nginx/conf/nginx.conf", "/opt/nginx/conf/nginx.conf.bak") unless File.exist? "/opt/nginx/conf/nginx.conf.bak"
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_'
+ rho_vhost_conf = <<_VHOST_CONF_
server {
listen 80;
-# server_name www.yourhost.com; # <-- your server domain name!
- root /opt/nginx/html/rhoapp/public; # <--- be sure to point to 'public' folder of your application!
+ root /opt/nginx/html/#{app_name}/public; # <-- be sure to point to 'public' folder of your application!
passenger_enabled on;
+# access_log off; # <-- disable access logging
+# error_log /dev/null crit; # <-- disable error logging, but critical errors only
}
_VHOST_CONF_
File.open('/opt/nginx/conf/conf.d/rhoconnect.conf', 'w' ) { |f| f << rho_vhost_conf }
passenger_conf = <<_PASSENGER_CONF_
@@ -548,21 +565,47 @@
Dir.chdir "../"
`chown -R nginx:nginx rhoapp/`
end
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 create_texts
if @redis
create_redis_init
create_redis_logrotate
end
if @server == 'nginx'
create_nginx_init
+
create_nginx_logrotate
- create_nginx_conf_files
- generate_rhoapp @prefix
+ @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
+
distro_info = nginx_readme
else
create_passenger_load
create_apache_vhost
distro_info = (@dist == 'debian') ? debian_apache_readme : yum_apache_readme
@@ -582,30 +625,44 @@
to your #{@profile} to automatically add them upon login.
export PATH=#{@prefix}/bin:$PATH
_IT_SHOULD_BE_DONE_
- puts afterwords +
- if @server == 'nginx'
- server_todo_list = <<_NGINX_TO_DO_
+ about_app =
+ if @use_bench_app
+ server_todo_list = <<_NGINX_TO_DO_
+2) Rhoconnect 'benchapp' application is created in /opt/nginx/html directory. To run it
+ A) As root user start redis and nginx servers:
+ /etc/init.d/redis start
+ /etc/init.d/nginx start
+ B) To verify that application up and running open web console in your browser:
+ http://localhost/console/
+
+_NGINX_TO_DO_
+ else
+ if @server == 'nginx'
+ server_todo_list = <<_NGINX_TO_DO_
2) Try rhoconnect 'rhoapp' application, created in /opt/nginx/html directory
A) As root user start redis and nginx servers:
/etc/init.d/redis start
/etc/init.d/nginx start
B) Open RhoConnect application web console in your browser:
http://localhost/console/
_NGINX_TO_DO_
- else
- server_todo_list = <<_APACHE2_TO_DO_
+ else
+ server_todo_list = <<_APACHE2_TO_DO_
2) Complete setup of Apache2 web server
A) Configure virtual host for your rhoconnect application:
Edit the file /etc/httpd/conf.d/rhoconnect.conf so that it reflects your specifications.
B) As root user start server to pick up the changes:
/sbin/service httpd start
_APACHE2_TO_DO_
- end + "For more details see #{@prefix}/README file."
+ end
+ end
+
+ puts afterwords + about_app + "For more details see #{@prefix}/README file."
end #create_texts
create_texts