Plugin updating is executed asynchronously by Quartz Scheduler

This commit is contained in:
Naoki Takezoe
2014-06-29 16:09:41 +09:00
parent 34dd8541f4
commit c64909ab1a
5 changed files with 80 additions and 25 deletions

View File

@@ -10,6 +10,7 @@ import util.Directory._
import util.ControlUtil._
import org.eclipse.jgit.api.Git
import util.Directory
import plugin.PluginUpdateJob
object AutoUpdate {
@@ -143,8 +144,14 @@ object AutoUpdate {
* Update database schema automatically in the context initializing.
*/
class AutoUpdateListener extends ServletContextListener {
import org.quartz.impl.StdSchedulerFactory
import org.quartz.JobBuilder._
import org.quartz.TriggerBuilder._
import org.quartz.SimpleScheduleBuilder._
import AutoUpdate._
private val logger = LoggerFactory.getLogger(classOf[AutoUpdateListener])
private val scheduler = StdSchedulerFactory.getDefaultScheduler
override def contextInitialized(event: ServletContextEvent): Unit = {
val datadir = event.getServletContext.getInitParameter("gitbucket.home")
@@ -181,11 +188,16 @@ class AutoUpdateListener extends ServletContextListener {
logger.debug("Starting plugin system...")
plugin.PluginSystem.init()
scheduler.start()
PluginUpdateJob.schedule(scheduler)
logger.debug("PluginUpdateJob is started.")
logger.debug("Plugin system is initialized.")
}
def contextDestroyed(sce: ServletContextEvent): Unit = {
// Nothing to do.
scheduler.shutdown()
}
private def getConnection(servletContext: ServletContext): Connection =