Re: [SR-Users] Kamailio htable mod-init route: Main process exited before writing to pipe

2017-10-02 Thread Daniel-Constantin Mierla
Hello,

this should be looked at and enhanced somehow to be supported.

An workaround would be to use a lua script via app_lua to do it. Or use
rtimer or timer module to do an execution with a condition on a $var(...)
to be executed only once.

Cheers,
Daniel

On Thu, Sep 28, 2017 at 10:14 PM, George Diamantopoulos <
georged...@gmail.com> wrote:

> Never mind, I'm certain by now:
>
> http://sip-router.1086192.n5.nabble.com/DB-select-htable-
> mod-init-doesn-t-work-td127717.html
> https://lists.kamailio.org/pipermail/sr-dev/2013-February/018484.html
>
> On 28 September 2017 at 22:18, George Diamantopoulos  > wrote:
>
>> Also, I' found this post by Daniel in 2014:
>>
>> https://lists.kamailio.org/pipermail/sr-users/2014-May/083155.html
>>
>> To quote:
>> > Indeed, the db connection is not initialized at the time of executing
>> > event_route[htable:mod-init]. This is executed after all modules are
>> > initialized, but the sqlops connections are initialized in child init.
>>
>> So maybe this is the case for 5.0.3 as well? sqlops functions can't be
>> used in event_route[htable:mod-init] yet?
>>
>>
>> On 28 September 2017 at 20:18, George Diamantopoulos <
>> georged...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I've tested again, this time including a single sql_pvquery function in
>>> the event-route. Kamailio will also exit with "daemonize(): Main process
>>> exited before writing to pipe" in this simpler case.
>>>
>>> In the documentation, it is stated that: The event route is executed
>>> only once, after core and module initialization, but before
>>> Kamailio forks any child processes.
>>>
>>> Does this mean that I don't have (perhaps) access to pseudovariables during 
>>> execution of this route? Is this the reason why kamailio exits prematurely?
>>>
>>> Thanks,
>>>
>>> George
>>>
>>>
>>> On 26 September 2017 at 15:37, George Diamantopoulos <
>>> georged...@gmail.com> wrote:
>>>
 I forgot to mention, I'm using Kamailio 5.0.3 on debian "stretch".

 On 26 September 2017 at 14:40, George Diamantopoulos <
 georged...@gmail.com> wrote:

> Hello all,
>
> I've been trying to utilise event_route[htable:mod-init] in order to
> load information from the database into an htable on startup. However,
> Kamailio exits with an error for no obvious (to me) reason. Here's the log
> output:
>
> DEBUG: htable [htable.c:226]: child_init(): rank is (-127)
> DEBUG: htable [htable.c:259]: child_init(): executing
> event_route[htable:mod-init] (2)
> DEBUG:  [core/parser/msg_parser.c:600]: parse_msg(): SIP
> Request:
> DEBUG:  [core/parser/msg_parser.c:602]: parse_msg():  method:
> 
> DEBUG:  [core/parser/msg_parser.c:604]: parse_msg():  uri: <
> sip:y...@kamailio.org>
> DEBUG:  [core/parser/msg_parser.c:606]: parse_msg():  version:
> 
> DEBUG:  [core/parser/parse_via.c:2639]: parse_via(): end of
> header reached, state=2
> DEBUG:  [core/parser/msg_parser.c:491]: parse_headers(): Via
> found, flags=2
> DEBUG:  [core/parser/msg_parser.c:493]: parse_headers(): this
> is the first via
> ERROR:  [core/daemonize.c:303]: daemonize(): Main process exited
> before writing to pipe
>
> And here's the routing block in kamailio.cfg. What I need to do is get
> the username for all non-expired contacts in the "location" table, perform
> a query on another database for each one of them and store the result in 
> an
> htable:
>
> event_route[htable:mod-init] {
>
> sql_pvquery("ck", "select username from location where now() <=
> expires", "$avp(registered_ng)");
>
> $var(i) = 0;
> while ( $(avp(registered_ng)[$var(i)]) != $null ) {
> sql_pvquery("ca", "select property from tablename where
> username = $(avp(registered_ng)[$var(i)])", "$var(ng_property)");
> $sht(isnguser=>$var(ng_property)) = 1;
> $var(i) = $var(i) + 1;
> pv_unset("$var(ng_property)");
> }
>
> pv_unset("$var(i)");
> }
>
> Any hints as to what I might be doing wrong? Thanks!
>
> Best regards,
> George
>


>>>
>>
>
> ___
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>


-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Kamailio htable mod-init route: Main process exited before writing to pipe

2017-09-28 Thread George Diamantopoulos
Never mind, I'm certain by now:

http://sip-router.1086192.n5.nabble.com/DB-select-htable-mod-init-doesn-t-work-td127717.html
https://lists.kamailio.org/pipermail/sr-dev/2013-February/018484.html

On 28 September 2017 at 22:18, George Diamantopoulos 
wrote:

> Also, I' found this post by Daniel in 2014:
>
> https://lists.kamailio.org/pipermail/sr-users/2014-May/083155.html
>
> To quote:
> > Indeed, the db connection is not initialized at the time of executing
> > event_route[htable:mod-init]. This is executed after all modules are
> > initialized, but the sqlops connections are initialized in child init.
>
> So maybe this is the case for 5.0.3 as well? sqlops functions can't be
> used in event_route[htable:mod-init] yet?
>
>
> On 28 September 2017 at 20:18, George Diamantopoulos  > wrote:
>
>> Hello,
>>
>> I've tested again, this time including a single sql_pvquery function in
>> the event-route. Kamailio will also exit with "daemonize(): Main process
>> exited before writing to pipe" in this simpler case.
>>
>> In the documentation, it is stated that: The event route is executed only
>> once, after core and module initialization, but before Kamailio
>> forks any child processes.
>>
>> Does this mean that I don't have (perhaps) access to pseudovariables during 
>> execution of this route? Is this the reason why kamailio exits prematurely?
>>
>> Thanks,
>>
>> George
>>
>>
>> On 26 September 2017 at 15:37, George Diamantopoulos <
>> georged...@gmail.com> wrote:
>>
>>> I forgot to mention, I'm using Kamailio 5.0.3 on debian "stretch".
>>>
>>> On 26 September 2017 at 14:40, George Diamantopoulos <
>>> georged...@gmail.com> wrote:
>>>
 Hello all,

 I've been trying to utilise event_route[htable:mod-init] in order to
 load information from the database into an htable on startup. However,
 Kamailio exits with an error for no obvious (to me) reason. Here's the log
 output:

 DEBUG: htable [htable.c:226]: child_init(): rank is (-127)
 DEBUG: htable [htable.c:259]: child_init(): executing
 event_route[htable:mod-init] (2)
 DEBUG:  [core/parser/msg_parser.c:600]: parse_msg(): SIP Request:
 DEBUG:  [core/parser/msg_parser.c:602]: parse_msg():  method:
 
 DEBUG:  [core/parser/msg_parser.c:604]: parse_msg():  uri: <
 sip:y...@kamailio.org>
 DEBUG:  [core/parser/msg_parser.c:606]: parse_msg():  version:
 
 DEBUG:  [core/parser/parse_via.c:2639]: parse_via(): end of
 header reached, state=2
 DEBUG:  [core/parser/msg_parser.c:491]: parse_headers(): Via
 found, flags=2
 DEBUG:  [core/parser/msg_parser.c:493]: parse_headers(): this is
 the first via
 ERROR:  [core/daemonize.c:303]: daemonize(): Main process exited
 before writing to pipe

 And here's the routing block in kamailio.cfg. What I need to do is get
 the username for all non-expired contacts in the "location" table, perform
 a query on another database for each one of them and store the result in an
 htable:

 event_route[htable:mod-init] {

 sql_pvquery("ck", "select username from location where now() <=
 expires", "$avp(registered_ng)");

 $var(i) = 0;
 while ( $(avp(registered_ng)[$var(i)]) != $null ) {
 sql_pvquery("ca", "select property from tablename where
 username = $(avp(registered_ng)[$var(i)])", "$var(ng_property)");
 $sht(isnguser=>$var(ng_property)) = 1;
 $var(i) = $var(i) + 1;
 pv_unset("$var(ng_property)");
 }

 pv_unset("$var(i)");
 }

 Any hints as to what I might be doing wrong? Thanks!

 Best regards,
 George

>>>
>>>
>>
>
___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Kamailio htable mod-init route: Main process exited before writing to pipe

2017-09-28 Thread George Diamantopoulos
Also, I' found this post by Daniel in 2014:

https://lists.kamailio.org/pipermail/sr-users/2014-May/083155.html

To quote:
> Indeed, the db connection is not initialized at the time of executing
> event_route[htable:mod-init]. This is executed after all modules are
> initialized, but the sqlops connections are initialized in child init.

So maybe this is the case for 5.0.3 as well? sqlops functions can't be used
in event_route[htable:mod-init] yet?

On 28 September 2017 at 20:18, George Diamantopoulos 
wrote:

> Hello,
>
> I've tested again, this time including a single sql_pvquery function in
> the event-route. Kamailio will also exit with "daemonize(): Main process
> exited before writing to pipe" in this simpler case.
>
> In the documentation, it is stated that: The event route is executed only
> once, after core and module initialization, but before Kamailio
> forks any child processes.
>
> Does this mean that I don't have (perhaps) access to pseudovariables during 
> execution of this route? Is this the reason why kamailio exits prematurely?
>
> Thanks,
>
> George
>
>
> On 26 September 2017 at 15:37, George Diamantopoulos  > wrote:
>
>> I forgot to mention, I'm using Kamailio 5.0.3 on debian "stretch".
>>
>> On 26 September 2017 at 14:40, George Diamantopoulos <
>> georged...@gmail.com> wrote:
>>
>>> Hello all,
>>>
>>> I've been trying to utilise event_route[htable:mod-init] in order to
>>> load information from the database into an htable on startup. However,
>>> Kamailio exits with an error for no obvious (to me) reason. Here's the log
>>> output:
>>>
>>> DEBUG: htable [htable.c:226]: child_init(): rank is (-127)
>>> DEBUG: htable [htable.c:259]: child_init(): executing
>>> event_route[htable:mod-init] (2)
>>> DEBUG:  [core/parser/msg_parser.c:600]: parse_msg(): SIP Request:
>>> DEBUG:  [core/parser/msg_parser.c:602]: parse_msg():  method:
>>> 
>>> DEBUG:  [core/parser/msg_parser.c:604]: parse_msg():  uri: <
>>> sip:y...@kamailio.org>
>>> DEBUG:  [core/parser/msg_parser.c:606]: parse_msg():  version:
>>> 
>>> DEBUG:  [core/parser/parse_via.c:2639]: parse_via(): end of
>>> header reached, state=2
>>> DEBUG:  [core/parser/msg_parser.c:491]: parse_headers(): Via
>>> found, flags=2
>>> DEBUG:  [core/parser/msg_parser.c:493]: parse_headers(): this is
>>> the first via
>>> ERROR:  [core/daemonize.c:303]: daemonize(): Main process exited
>>> before writing to pipe
>>>
>>> And here's the routing block in kamailio.cfg. What I need to do is get
>>> the username for all non-expired contacts in the "location" table, perform
>>> a query on another database for each one of them and store the result in an
>>> htable:
>>>
>>> event_route[htable:mod-init] {
>>>
>>> sql_pvquery("ck", "select username from location where now() <=
>>> expires", "$avp(registered_ng)");
>>>
>>> $var(i) = 0;
>>> while ( $(avp(registered_ng)[$var(i)]) != $null ) {
>>> sql_pvquery("ca", "select property from tablename where username
>>> = $(avp(registered_ng)[$var(i)])", "$var(ng_property)");
>>> $sht(isnguser=>$var(ng_property)) = 1;
>>> $var(i) = $var(i) + 1;
>>> pv_unset("$var(ng_property)");
>>> }
>>>
>>> pv_unset("$var(i)");
>>> }
>>>
>>> Any hints as to what I might be doing wrong? Thanks!
>>>
>>> Best regards,
>>> George
>>>
>>
>>
>
___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Kamailio htable mod-init route: Main process exited before writing to pipe

2017-09-28 Thread George Diamantopoulos
Hello,

I've tested again, this time including a single sql_pvquery function in the
event-route. Kamailio will also exit with "daemonize(): Main process exited
before writing to pipe" in this simpler case.

In the documentation, it is stated that: The event route is executed only
once, after core and module initialization, but before Kamailio
forks any child processes.

Does this mean that I don't have (perhaps) access to pseudovariables
during execution of this route? Is this the reason why kamailio exits
prematurely?

Thanks,

George


On 26 September 2017 at 15:37, George Diamantopoulos 
wrote:

> I forgot to mention, I'm using Kamailio 5.0.3 on debian "stretch".
>
> On 26 September 2017 at 14:40, George Diamantopoulos  > wrote:
>
>> Hello all,
>>
>> I've been trying to utilise event_route[htable:mod-init] in order to load
>> information from the database into an htable on startup. However, Kamailio
>> exits with an error for no obvious (to me) reason. Here's the log output:
>>
>> DEBUG: htable [htable.c:226]: child_init(): rank is (-127)
>> DEBUG: htable [htable.c:259]: child_init(): executing
>> event_route[htable:mod-init] (2)
>> DEBUG:  [core/parser/msg_parser.c:600]: parse_msg(): SIP Request:
>> DEBUG:  [core/parser/msg_parser.c:602]: parse_msg():  method:
>> 
>> DEBUG:  [core/parser/msg_parser.c:604]: parse_msg():  uri: <
>> sip:y...@kamailio.org>
>> DEBUG:  [core/parser/msg_parser.c:606]: parse_msg():  version:
>> 
>> DEBUG:  [core/parser/parse_via.c:2639]: parse_via(): end of header
>> reached, state=2
>> DEBUG:  [core/parser/msg_parser.c:491]: parse_headers(): Via
>> found, flags=2
>> DEBUG:  [core/parser/msg_parser.c:493]: parse_headers(): this is
>> the first via
>> ERROR:  [core/daemonize.c:303]: daemonize(): Main process exited
>> before writing to pipe
>>
>> And here's the routing block in kamailio.cfg. What I need to do is get
>> the username for all non-expired contacts in the "location" table, perform
>> a query on another database for each one of them and store the result in an
>> htable:
>>
>> event_route[htable:mod-init] {
>>
>> sql_pvquery("ck", "select username from location where now() <=
>> expires", "$avp(registered_ng)");
>>
>> $var(i) = 0;
>> while ( $(avp(registered_ng)[$var(i)]) != $null ) {
>> sql_pvquery("ca", "select property from tablename where username
>> = $(avp(registered_ng)[$var(i)])", "$var(ng_property)");
>> $sht(isnguser=>$var(ng_property)) = 1;
>> $var(i) = $var(i) + 1;
>> pv_unset("$var(ng_property)");
>> }
>>
>> pv_unset("$var(i)");
>> }
>>
>> Any hints as to what I might be doing wrong? Thanks!
>>
>> Best regards,
>> George
>>
>
>
___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Kamailio htable mod-init route: Main process exited before writing to pipe

2017-09-26 Thread George Diamantopoulos
I forgot to mention, I'm using Kamailio 5.0.3 on debian "stretch".

On 26 September 2017 at 14:40, George Diamantopoulos 
wrote:

> Hello all,
>
> I've been trying to utilise event_route[htable:mod-init] in order to load
> information from the database into an htable on startup. However, Kamailio
> exits with an error for no obvious (to me) reason. Here's the log output:
>
> DEBUG: htable [htable.c:226]: child_init(): rank is (-127)
> DEBUG: htable [htable.c:259]: child_init(): executing
> event_route[htable:mod-init] (2)
> DEBUG:  [core/parser/msg_parser.c:600]: parse_msg(): SIP Request:
> DEBUG:  [core/parser/msg_parser.c:602]: parse_msg():  method:
> 
> DEBUG:  [core/parser/msg_parser.c:604]: parse_msg():  uri: <
> sip:y...@kamailio.org>
> DEBUG:  [core/parser/msg_parser.c:606]: parse_msg():  version:
> 
> DEBUG:  [core/parser/parse_via.c:2639]: parse_via(): end of header
> reached, state=2
> DEBUG:  [core/parser/msg_parser.c:491]: parse_headers(): Via found,
> flags=2
> DEBUG:  [core/parser/msg_parser.c:493]: parse_headers(): this is
> the first via
> ERROR:  [core/daemonize.c:303]: daemonize(): Main process exited
> before writing to pipe
>
> And here's the routing block in kamailio.cfg. What I need to do is get the
> username for all non-expired contacts in the "location" table, perform a
> query on another database for each one of them and store the result in an
> htable:
>
> event_route[htable:mod-init] {
>
> sql_pvquery("ck", "select username from location where now() <=
> expires", "$avp(registered_ng)");
>
> $var(i) = 0;
> while ( $(avp(registered_ng)[$var(i)]) != $null ) {
> sql_pvquery("ca", "select property from tablename where username =
> $(avp(registered_ng)[$var(i)])", "$var(ng_property)");
> $sht(isnguser=>$var(ng_property)) = 1;
> $var(i) = $var(i) + 1;
> pv_unset("$var(ng_property)");
> }
>
> pv_unset("$var(i)");
> }
>
> Any hints as to what I might be doing wrong? Thanks!
>
> Best regards,
> George
>
___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users