Forum OpenACS Q&A: Figuring out location without a connnection

I have a bad feeling that this a stupid question, that the answer is
obvious, but I can't seem to figure it out so here goes:

I have two sites, staging and live, which share the same codebase via
CVS.  They access the same database, so in some places I want to not
run the scheduled procs for the staging site.  That means that the
script which does the scheduling needs to know which site it's being
executed on.

I would normally do this with "ns_conn location", but that doesn't
work here as there is no connection when this code is executed.  The
only things which will identify the site for me are the
location/hostname or the path of the script, and I can't figure out
how to get either.

Can someone please tell me what I'm overlooking?

Collapse
Posted by Jade Rubick on
It seems like it would be a nice thing to add into OpenACS: knowledge of what type of installation it is. If we created a few simple functions that could determine what the server was (staging, development, production), then we could do a lot of neat things like wrap ns_sendmail with a debug mail operation to the developer when it is a developer site, etc...

Sorry, that doesn't answer your question. I haven't run into this problem personally, as I keep copies of the production database on my production server. I don't see why this couldn't be done for staging as well..

Collapse
Posted by Don Baccus on
[ad_conn file] should give you the path of the script ...
Collapse
Posted by Janine Ohmer on
Unfortunately, ad_conn doesn't work without a connection either.

The reason the two sites share a database is that the client wants it that way;  they're willing to give up the safety of having two for convenience of having the same data on both sites, without having to enter it twice.

Collapse
Posted by Tom Jackson on

How about [ns_info server]?

Collapse
Posted by Janine Ohmer on
Thanks, Tom, that works!
Collapse
Posted by David Walker on
We put the following in the nsd.tcl of the dev server
ns_section "ns/server/${server}/acs/special_parameters"
ns_param dev_server true

and check

 if {![string is true [ad_parameter dev_server special_parameters]] } {
	do stuff on live server
}