CleanMasonCache

From Request Tracker Wiki
Jump to navigation Jump to search

Each file in the share/html directory is a mason component. Mason precompiles these files into Perl code and stores precompiled files in the cache dir. This feature speeds up processing as it doesn't need to recompile components each time. Also we can turn off checks on the original components if recompilation is required. Skipping such tests is done to speed up things more. RT uses both of these features. So when you change anything in the share/html or local/html directories, you must clear the mason cache to see changes. To clear the cache, run this command:

shell> rm -rf /opt/rt3/var/mason_data/obj/*

NOTE Your path to RT may differ if you're using a packaged version of RT. Please, enter below paths for your OS distribution.

RedHat / CentOS

Manual:

Locate your RT install directory, in our case /usr/local/rt4

rm -Rf /usr/local/rt4/var/mason_data/obj/*


Scripted:

unset _response
_rt=$(find /opt /usr -name mason_data)

while [[ ( ${_response} != 'n' ) && ( ${_response} != 'N' ) && ( ${_response} != 'y' ) && ( ${_response} != 'Y' ) ]]; do
    read -p "Clearing mason cache in ${_rt}, continue? 'y/N': " _response
done

if [[ ( ${_response} == 'y' ) || ( ${_response} == 'Y' ) ]]; then
{
    echo -n "Clearing mason cache in ${_rt}: "
    rm -rf ${_rt}/obj/*
    _status=${?}

    if [[ ${_status} == 0 ]]; then 
    {
        echo "[ SUCCESS ]"
    }
    else
    {
        echo "[ FAIL ]"
    }
    fi
}
else
{
    echo 'Exiting without clearning mason cache'
}
fi

SUSE/openSUSE

Assuming you have installed RT via the request-tracker package (as you should have), just run the /usr/sbin/rt-clean-mason-cache script as root.

FreeBSD

In FreeBSD, all third-party software is installed in /usr/local/, so the command would be:

   rm -rf /usr/local/rt3/var/mason_data/obj/*

except for recent RT4 portbuild, where the RT var directory becomes /var/run/rt40

So the command is

   rm -rf /var/run/rt40/mason_data/obj/*

Debian & Ubuntu

If you're using Debian packages then the filesystem location mentioned above is more likely to be /var/cache/request-tracker3.4/mason_data

It may also be useful to know that DevelMode requires a Perl module called Module::Refresh, a package for which is not easily found. So if you're hacking on something and want to see the changes, you can clear the cache and restart Apache in one go like so:

   find /var/cache/request-tracker3.4/mason_data/ -type f -print0 | xargs -0 rm -f ; /etc/init.d/apache2 restart

For developers

The DevelMode option allows you to avoid this step, but note that you don't want to use this option in production environment.