本文介绍了仅在第一个请求之后才触发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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 20:27