GlobalSettings onStart 仅在第一次请求后触发 [英] GlobalSettings onStart fires only after first request

查看:28
本文介绍了GlobalSettings onStart 仅在第一次请求后触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动播放服务器时,我只需要运行一些代码.使用 GlobalSettings.OnStart() 时,我注意到代码仅在对服务器的第一个 (http) 请求之后执行.知道如何在服务器启动后和发送任何请求之前运行我的代码吗?

I need to run some code only once when I starts the play server. When using the GlobalSettings.OnStart() I notice that the code is executed only after the first (http) request to the server. Any idea how can I run my code just after the server starts and before any request is sent?

谢谢

推荐答案

即应用处于开发模式时的行为,play run.当它在生产模式下运行时,play start,那么你的 onStart 方法将在应用程序在任何请求之前启动时立即运行.

That is the behavior when the application is in development mode, play run. When it's running in production mode, play start, then your onStart method will run immediately when the application starts prior to any requests.

这篇关于GlobalSettings onStart 仅在第一次请求后触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆