Saturday, August 27, 2011

Set up Apache for site maintenace

We want to set up the site maintenance page from 5am to 3pm on a certain day to do database upgrade. Then we want to test the site internally before opening to the public. This is what I would do in Apache configuration:

# rewrite condition1: 5am to 3pm
# rewrite condition2: allow only internal ip
# rewrite condition3: any database driven page (".dyn", ".jsp", or ".vm")

RewriteCond %{TIME_HOUR}%{TIME_MIN} >0500
RewriteCond %{TIME_HOUR}%{TIME_MIN} <1500
RewriteCond %{REMOTE_ADDR} !^255.255.0.0*$
RewriteCond %{REQUEST_URI} \.(dyn|jsp|vm)$
RewriteRule ^/(.+)$ http://my.site.com:80/sitedown.html [L,R]

Wednesday, August 10, 2011

Can't deploy / undeploy web applications on Glassfish

When we tried to publish a new web application to Glassfish (v2.1.1) this morning, we got the following mystic message:

CLI171 Command deploy failed : While redeploying, trying to stop the application in target server failed; Error Flushing ConfigContext com.sun.enterprise.config.ConfigContext: Url=$glassfish_home/domains/release/config/domain.xml, ReadOnly=false, ResolvePath=true, LastModified Timestamp=1312828827000, isChanged=false, Autocommit=false, isConfigBeanNull=false

It took us a while to realize that somehow domain.xml lost the write permission overnight, so Glassfish cannot add or delete the web application in domain.xml.

Glassfish team should hire someone who can write messages for a normal human being :)

How to start/stop all the cron jobs on Linux

Log in as root on the server:

All the cron jobs are defined in /var/spool/cron

To stop all cron jobs: /etc/init.d/crond stop

To start all cron jobs: /etc/init.d/crond start