2013年5月23日 星期四

Nginx

1. Install Nginx on CentOS

 sudo yum install nginx  

  A. Install the EPEL repository (No package nginx available)
 
 sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm  
 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6  


  B. Change EPEL 5 version of the repo instead of 6
           Error: Package: nginx-0.8.55-2.el5.x86_64 (epel)
           Requires: perl(:MODULE_COMPAT_5.8.8)

 vi /etc/yum.repos.d/epel.repo  
 #mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch  
 mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch  
 yum clean all  
 yum install munin --nogpgcheck  

2. Configration
          The default vhost is defined in the file /etc/nginx/conf.d/default.conf.
          My case is setting up a reverse proxy to a Tomcat.

location /webportal {
   proxy_pass http://localhost:8080/;
   proxy_redirect   http://localhost:8080/    http://$host:$server_port/;
   proxy_set_header Host $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

3. Start

 sudo /etc/init.d/nginx start  




Reference :
http://articles.slicehost.com/2008/12/17/centos-installing-nginx-via-yum
http://gingerjoos.com/blog/linux/installing-jetty-on-centos


2013年4月22日 星期一

ThreadPoolExecutor waitForTasksToCompleteOnShutdown doesn't work as expected

https://jira.springsource.org/browse/SPR-5387


ThreadPoolTaskExecutor doesn't work when setting up the WaitForTasksToCompleteOnShutdown property as true, also need to set up the AwaitTerminationSeconds property.


@Bean
public ThreadPoolTaskExecutor processTaskExecutor() {
   ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
   taskExecutor.setCorePoolSize(5);
   taskExecutor.setMaxPoolSize(10);
   taskExecutor.setQueueCapacity(40);
   taskExecutor.setKeepAliveSeconds(200);
   taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
   taskExecutor.setAwaitTerminationSeconds(60);
   taskExecutor.setThreadFactory(new CustomizableThreadFactory("DeployThread"));
   return taskExecutor;
}