@@ -363,6 +363,10 @@ ngx_[% subsys %]_lua_ngx_timer_helper(lua_State *L, int every)
363363
364364 ngx_add_timer (ev , delay );
365365
366+ ngx_log_debug2 (NGX_LOG_DEBUG_ [% SUBSYS %], ngx_cycle -> log , 0 ,
367+ "[% log_prefix %]created timer (co: %p delay: %M ms)" ,
368+ tctx -> co , delay );
369+
366370 lua_pushinteger (L , 1 );
367371 return 1 ;
368372
@@ -523,6 +527,10 @@ ngx_[% subsys %]_lua_timer_copy(ngx_[% subsys %]_lua_timer_ctx_t *old_tctx)
523527
524528 ngx_add_timer (ev , tctx -> delay );
525529
530+ ngx_log_debug2 (NGX_LOG_DEBUG_ [% SUBSYS %], ngx_cycle -> log , 0 ,
531+ "[% log_prefix %]created next timer (co: %p delay: %M ms)" ,
532+ tctx -> co , tctx -> delay );
533+
526534 return NGX_OK ;
527535
528536nomem :
@@ -607,6 +615,9 @@ ngx_[% subsys %]_lua_timer_handler(ngx_event_t *ev)
607615
608616 c = ngx_ [% subsys %]_lua_create_fake_connection (tctx .pool );
609617 if (c == NULL ) {
618+ ngx_log_error (NGX_LOG_ALERT , ngx_cycle -> log , 0 ,
619+ "[% log_prefix %]failed to create fake connection to "
620+ "run timer (co: %p)" , tctx .co );
610621 goto failed ;
611622 }
612623
@@ -619,13 +630,18 @@ ngx_[% subsys %]_lua_timer_handler(ngx_event_t *ev)
619630[% IF stream_subsys %]
620631 s = ngx_stream_lua_create_fake_session (c );
621632 if (s == NULL ) {
633+ ngx_log_error (NGX_LOG_ALERT , ngx_cycle -> log , 0 ,
634+ "stream lua failed to create fake session to run timer "
635+ "(co: %p)" , tctx .co );
622636 goto failed ;
623637 }
624- [% END %]
625638
626- [% IF http_subsys %]
639+ [% ELSIF http_subsys %]
627640 r = ngx_http_lua_create_fake_request (c );
628641 if (r == NULL ) {
642+ ngx_log_error (NGX_LOG_ALERT , ngx_cycle -> log , 0 ,
643+ "failed to create fake request to run timer (co: %p)" ,
644+ tctx .co );
629645 goto failed ;
630646 }
631647[% END %]
@@ -682,6 +698,9 @@ ngx_[% subsys %]_lua_timer_handler(ngx_event_t *ev)
682698 ctx = ngx_stream_lua_create_ctx (s );
683699[% END %]
684700 if (ctx == NULL ) {
701+ ngx_log_error (NGX_LOG_ALERT , ngx_cycle -> log , 0 ,
702+ "[% log_prefix %]failed to create ctx to run timer "
703+ "(co: %p)" , tctx .co );
685704 goto failed ;
686705 }
687706
@@ -694,6 +713,9 @@ ngx_[% subsys %]_lua_timer_handler(ngx_event_t *ev)
694713
695714 pcln = ngx_pool_cleanup_add (r -> pool , 0 );
696715 if (pcln == NULL ) {
716+ ngx_log_error (NGX_LOG_ALERT , ngx_cycle -> log , 0 ,
717+ "[% log_prefix %]failed to add vm cleanup to run "
718+ "timer (co: %p)" , tctx .co );
697719 goto failed ;
698720 }
699721
@@ -707,6 +729,9 @@ ngx_[% subsys %]_lua_timer_handler(ngx_event_t *ev)
707729
708730 cln = ngx_ [% req_subsys %]_cleanup_add (r , 0 );
709731 if (cln == NULL ) {
732+ ngx_log_error (NGX_LOG_ALERT , ngx_cycle -> log , 0 ,
733+ "[% log_prefix %]failed to add request cleanup to run "
734+ "timer (co: %p)" , tctx .co );
710735 goto failed ;
711736 }
712737
0 commit comments