LSAPI not working with ODBC

#1
We have an application that we have been testing with lighty+fastcgi and nginx+mongrel. Before we make a final decision on how we want to deploy it, we wanted to give LiteSpeed+LSAPI a try.

The only hiccup in our setup is we are forced to use SQL Server as our database. Our apps run on Linux so we use unixODBC and FreeTDS to connect to the database.

Our app has no problems connecting to the database with the lighty or nginx configurations. However, with LiteSpeed we always get the following error:

[unixODBC][Driver Manager]Data source name not found, and no default driver specified

I have tried setting up LSAPI the easy way and the step by step way and in each case I end up with the same error.

The lighty and nginx installations automatically use our ODBC setup in /etc/odbc.ini. Our database.yml entry matches one of the DSNs in odbc.ini, like so:

production:
adapter: sqlserver
mode : odbc
dsn : TOPAZ

Is there anything I can do to get LiteSpeed to use /etc/odbci.ini or another way I can give LSAPI the DSN information?
 

mistwang

LiteSpeed Staff
#2
I think you need to add special environment variables explicitly uner the "Ruby Rails" tab. Most shell environment variables are stripped.
 
#3
I tried making adapter, mode and dsn environment variables under the Ruby Rails tab. I am still getting the same error. Did you have specific env vars in mind?
 
#5
I checked our environment variables and we have two of them:
ODBCSYSINI=/etc
ODBCINI=/etc/odbc.ini

I added those to the Ruby Rails tab and restarted LiteSpeed. No luck. Same error.
 

mistwang

LiteSpeed Staff
#6
Maybe you need to double check the permission with /etc/odbc.ini to make sure that the user that railsrunner run as has read permission.

Also, you can try "strace" the ruby process.
 
#7
Permissions are not the problem. The web server user can read the file.

I would have no problem strace'ng the Ruby process if I were running it myself. As the web server is controlling it on its own, I will have to poke around to see where I can insert that into the process.
 
#9
Good tip on strace. I can now see the cause of the problem. It is looking for /usr/local/etc/odbc.ini, /usr/local/etc/odbcinst.ini and /home/app/.odbc.ini. The environment variables I added yesterday aren't pushing it to the correct ODBC install in /etc.
 
Top