Thanks Massimo. That clears things up.Really the only rivet function I'm calling from my sql driver is ::rivet::apache_log_error, so if I eliminate that then it will run.
I will have a look at the tcl-syslog package. I think I'll have to replace the ::rivet::apache_log_error calls with my own log method and that can choose where to send the stuff. That might be more useful in the long run and also work around this problem.
Kind regards, Scott On 2/6/24 04:15, Massimo Manghi wrote:
Hi ScottBy now mod_rivet related code need modifications for your approach to work. See my comments belowOn 6/1/24 14:51, Scott Pitcher wrote:Hi,In a tcl source module in my Rivet website I'm launching a thread to handle periodic database management. I'm having trouble getting that thread to log to the apache log.Part of the SetupDatabase proc launches the thread with - tsv::set [namespace current] Tid [thread::create -preserved [subst { ## Give the new thread access to the same website code base and copy the# module configuration over. # set auto_path "$::auto_path" namespace eval [namespace current] { array set Config \{[array get Config]\} }[namespace current]::Log "(\[pid\]) New thread created at \[clock format \[clock seconds\]\]"if {\[catch "package require Rivet" output ropts\]} {[namespace current]::Log "(\[pid\]) package require Rivet failed: \$output"} thread::wait ; # DEBUGrequiring package Rivet is not enough. Your example is highlighting a rigidity, but I don't know if it would make sense to have the whole command set available to other threads. Let me explain: in mod_rivet the set up of a Tcl interpreter is done in Rivet_PerInterpInit (src/mod_rivet_ng/mod_rivet_common.c). From there package Rivet is loaded calling Tcl_PkgRequire after Rivet_InitCore is called (sets up most of the command set, ::rivet::inspect included) and other stuff is prepared. Among these tasks also the interpreter associated data structure is prepared. This structure carries a reference to the server_rec pointer required by ::rivet::apache_log_error to work properly (actually to work at all...)in other words in rivet/init.tcl (which provides package Rivet) we put stuff that could easily done in Tcl instead of C but it's kind of a helper package for Rivet_PerInterpInit.The Log function was created to capture some logging output and it simply appends the message into a log file in the website's tmp directory (adjacent directory to the source files). I can see in this log file that the new thread is created (line 2) but the "package require Rivet" fails with the "invalid command name ::rivet::inspect" (line 3)?(31279) SetupDatabase: Launching the management thread. (31279) New thread created at Sat Jun 01 22:26:40 AEST 2024(31279) package require Rivet failed: invalid command name "::rivet::inspect"Can we have rivet commands loaded in other threads? I don't know if 'ts possible easily and I don't know if it makes sense: many ::rivet commands have to do with HTTP requests data. What you're outlining is a monitor thread that works independently of HTTP request processing....what if you had the monitor threads run in a separate process and have rivet threads communicate using unix sockets (https://github.com/cyanogilvie/unix_sockets) and logging using syslog (https://github.com/mxmanghi/tcl-syslog)?regards -- MassimoA test message from the thread at Sat Jun 01 22:26:40 AEST 2024 A test message from the thread at Sat Jun 01 22:26:41 AEST 2024 scotty@server1:/home/Shares/Engineering/Web/SVP-Technical-Services$I'm trying to load the Rivet package in this new thread because I want to use the ::rivet::apache_log_error function. It's rather opaque inside the thread and I have to examine the sqlite data base operations. It's certainly not doing maintenance correctly.Am I do this correctly by trying to package require Rivet?I know that if I try to call ::rivet::apache_log_error from inside the thread protected by catch I get:(32512) New thread created at Sat Jun 01 22:46:31 AEST 2024(32512) ::rivet::apache_log_error failed: invalid command name "::rivet::apache_log_error"Kind regards, Scott
-- +-----------------------------------------------------------------------------+ |...will make the wilderness a pool of water, the dry land springs of water...| +-----------------------------------------------------------------------------+ | Scott Pitcher [email protected] | | +61-3-9008-5695 (B) SVP Technical Services | |PGP: https://gnupg.org/ ABN 79 220 496 603 | |KEY: https://pgp.mit.edu/pks/lookup?op=vindex&search=0xEDBE43639EFD884D | +-----------------------------------------------------------------------------+ DISCLAIMER: The content of this email is confidential and strictly intended only for the recipient(s) specified in the message. If you have received this message by mistake it is strictly forbidden to keep this email in any form, electronic or hard copy, or to share any part of it with any one else, without the prior, written consent of the author. If you have received this message by mistake, please let me know by replying to this email, and then destroy it and any copies. SECURITY: I prefer to send and receive confidential messages protected by PGP public key encryption. If you are willing to or are interested in protecting our email communication with PGP encryption, please refer to https://gnupg.org/.
OpenPGP_0xEDBE43639EFD884D.asc
Description: OpenPGP public key
OpenPGP_signature.asc
Description: OpenPGP digital signature
