LSAPI not working with ODBC

Discussion in 'Ruby/Rails' started by mavaca, Dec 21, 2007.

  1. mavaca

    mavaca New Member

    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?
  2. mistwang

    mistwang LiteSpeed Staff

    I think you need to add special environment variables explicitly uner the "Ruby Rails" tab. Most shell environment variables are stripped.
  3. mavaca

    mavaca New Member

    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?
  4. mistwang

    mistwang LiteSpeed Staff

    Any environment variable related to unixODBC setup should be set.
    You can try add all envirnonment available under your shell.
  5. mavaca

    mavaca New Member

    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.
  6. mistwang

    mistwang LiteSpeed Staff

    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. mavaca

    mavaca New Member

    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.
  8. mistwang

    mistwang LiteSpeed Staff

    Try a URL like the rails property page to have the ruby process started, then strace it.
  9. mavaca

    mavaca New Member

    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.

Share This Page