In Grails if we want to execute code on application startup and stop time . We just need to write our code in grails-app/conf/BootStrap.groovy file.Here we have two closure.

1. init  :- Here we write code that we have need to execute at application startup time.

2. destroy  :- Here we write code that we have need to execute at application stop time.

But we are not limited to one BootStrap class file.We can create multiple BootStrap classes as long as these are placed in the grails-app/conf directory and the name end with BootStrap.

// File: grails-app/conf/BootStrap.groovy
class BootStrap {
    def init = { servletContext ->
       println "Running init method for first BootStrap"
    }
    def destroy = {
       println "Running destroy method for first BootStrap"
    }
}
 // File: grails-app/conf/SecondBootStrap.groovy
class SecondBootStrap {
    def init = { servletContext ->
        println "Running init method for SecondBootStrap"
    }
    def destroy = {
        println "Running destroy method for SecondBootStrap"
    }