"child exited with status 13" when trying to run fastcgi examples with lighttpd - fastcgi

I have compiled fastcgi c-api examples: http://www.fastcgi.com/devkit/examples/
They work fine when I execute them manually in the command line (by typing ./echo for example) but I have some troubles when I try to make it work with lighttpd.
"/echo.fcgi" => (
"localhost" => (
"socket" => "/tmp/echo.sock",
"bin-path" => "/Users/onur/Downloads/fcgi-2.4.0/examples/tiny",
"check-local" => "disable"
),
)
new-host:examples onur$ ls -la echo
-rwxr-xr-x 1 _www _www 3322 Aug 4 21:21 echo
What am I missing? What are the specificities of the execution of a binary with fastcgi in lighttpd?

shouldn't this:
"bin-path" => "/Users/onur/Downloads/fcgi-2.4.0/examples/tiny",
be something like this, instead?
"bin-path" => "/Users/onur/Downloads/fcgi-2.4.0/examples/echo",
you are trying to run echo and not tiny, aren't you?

Related

NetSuite 64bit ODBC Driver installation on Ubuntu 18.04 Cluster giving error:- Can't open lib '/opt/netsuite/odbcclient/lib64/ivoa27.so

Have been running around this issue since 2-3 days now with no luck. Hope someone guides me and help resolve this issue here.
I am running a Python application from /home/admin/app/example.py directory in a 3 node Ubuntu 18.04 clustered environment which is supposed to connect to NetSuite via ODBC and read list of tables. The code and directory setup is same across all 3 nodes. There's a load balancer routing request to all these 3 nodes.
Here's example how the connection is made via PyODBC module:
import pyodbc
cnxn = pyodbc.connect('DSN=NetSuite;UID=user;PWD=pass'.format(dsn, uid, pwd), autocommit=True)
cursor=cnxn.cursor()
tables_list = []
for row in cursor.tables():
tables_list.append(row.table_name)
print (tables_list)
However, while running the python application on cluster, I am always getting error as:- Can't open lib '/opt/netsuite/odbcclient/lib64/ivoa27.so; even though the driver file, all its dependencies (via ldd command) and all the path variables i.e. $LD_LIBRARY_PATH, $ODBCINI and $OASDK_ODBC_HOME exists and is set to be available system-wide (added under /etc/environment file) as below on all the 3 nodes:
PYTHON_APP_HOME=/home/admin/app/
LD_LIBRARY_PATH="/opt/netsuite/odbcclient/lib64"
ODBCINI="/opt/netsuite/odbcclient/odbc64.ini"
OASDK_ODBC_HOME="/opt/netsuite/odbcclient/lib64"
Here's the output from "ldd" command for driver dependencies:
-rwxr-xr-x 1 root root 3277375 Jul 25 16:03 ivoa27.so
/opt/netsuite/odbcclient/lib64$ ldd /opt/netsuite/odbcclient/lib64/ivoa27.so
linux-vdso.so.1 (0x00007fff401a2000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fee1d589000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fee1d385000)
libicuuc.so.42 => /opt/netsuite/odbcclient/lib64/libicuuc.so.42 (0x00007fee1d12b000)
libicudata.so.42 => /opt/netsuite/odbcclient/lib64/libicudata.so.42 (0x00007fee1c0e6000)
libpam.so.0 => /lib/x86_64-linux-gnu/libpam.so.0 (0x00007fee1bed8000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fee1bcb9000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fee1b930000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fee1b592000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fee1b37a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fee1af89000)
/lib64/ld-linux-x86-64.so.2 (0x00007fee1db3c000)
libaudit.so.1 => /lib/x86_64-linux-gnu/libaudit.so.1 (0x00007fee1ad60000)
libcap-ng.so.0 => /lib/x86_64-linux-gnu/libcap-ng.so.0 (0x00007fee1ab5b000)
Below is how the steps were performed as per Netsuite driver README.txt instructions and the ODBC driver is setup similarly across all the 3 nodes on Ubuntu 18.04 OS.
The Netsuite 64bit Linux driver files/folders are unpacked and copied at location:
$cd /opt/netsuite/odbcclient/*. This entire dir,sub-dir & files within have both r+x permissions.
Installed libraries $sudo apt install unixodbc && apt-get install unixodbc-dev
Executed script/command provided by Netsuite from dir /opt/netsuite/odbcclient:- $source oaodbc64.sh (since it's a bash shell). This sets up the same variables as shown above.
From the same directory/folder ran below command for registering it as system-wide Driver:
$sudo odbcinst -i -d -f /opt/netsuite/odbcclient/odbcinst.ini
which returned message as:
odbcinst: Driver installed. Usage count increased to 1.
Target directory is /etc
odbcinst: Driver installed. Usage count increased to 1.
Target directory is /etc
Then ran below command also for installing it as system DSN:-
$sudo odbcinst -i -s -l -f /opt/netsuite/odbcclient/odbc64.ini
After this, checked /etc directory where both odbc.ini and odbcinst.ini files where created/registered. Both *.ini files were also given execute permissions to all.
-rwxr-xr-x 1 root root 500 Jul 24 10:31 odbc.ini
-rwxr-xr-x 1 root root 199 Jul 24 10:31 odbcinst.ini
$odbcinst -j
unixODBC 2.3.4
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /opt/netsuite/odbcclient/odbc64.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
$odbcinst -q -d
[ODBC Drivers]
[NetSuite ODBC Drivers 8.1]
$odbcinst -q -s
[NetSuite]
[ODBC]
I am also able to connect from each individual nodes via isql and also by running the example.py via python shell locally.
$isql -v 'NetSuite' 'user' 'pass'
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
But when running the same on cluster, it gives same error always. Please help. I am sure am missing something.
Here's the output of odbc.ini and odbcinst.ini files from /etc directory:
/etc$ more odbcinst.ini
[ODBC Drivers]
NetSuite ODBC Drivers 8.1=Installed
UsageCount=1
[NetSuite ODBC Drivers 8.1]
APILevel=1
ConnectFunctions=YYN
Driver=ivoa27.so
DriverODBCVer=03.52
FileUsage=0
SQLLevel=1
UsageCount=1
/etc$ more odbc.ini
[ODBC Data Sources]
NetSuite=NetSuite ODBC Drivers 8.1
[NetSuite]
Driver=/opt/netsuite/odbcclient/lib64/ivoa27.so
Description=Connect to your NetSuite account
Host=XXXXX.connect.api.netsuite.com
Port=1708
ServerDataSource=NetSuite.com
Encrypted=1
Truststore=/opt/netsuite/odbcclient/cert/ca3.cer
CustomProperties=AccountID=XXXXX;RoleID=XXXX
[ODBC]
Trace=0
IANAAppCodePage=4
TraceFile=odbctrace.out
TraceDll=/opt/netsuite/odbcclient/lib64/ddtrc27.so
InstallDir=/opt/netsuite/odbcclient
Tried below other things that didn't work:
Added ODBC variable paths within .profile,.bashrc ,/etc/profile,/etc/bash.bashrc other than /etc/environment.
Changed the owner of /lib64/ folder and all files within it and *.ini files under /etc from root to admin.
By creating symbolic links:
sudo ln -s /etc/odbcinst.ini /usr/local/etc/odbcinst.ini
sudo ln -s /etc/odbc.ini /usr/local/etc/odbc.ini
Thanks !!
UPDATE - SOLVED !! One important step that was missing from our end was the reboot/restart of all the nodes for those 3 variables to take into system-wide effect after it had been added into /etc/environment file(s).
In order to investigate, we printed below additional things into our code to ensure that it indeed is a 64 bit platform/architecture, drivers and datasources are registered and listed. However, the variables were still showing blanks/none. That verified that although the variable path was set/effective locally when running from individual nodes. However, when running from outside/via remote session, the variable values didn't get apply.
import os
import pyodbc
import platform
print(platform.architecture())
print (pyodbc.drivers())
print(pyodbc.dataSources())
print(os.environ["LD_LIBRARY_PATH"])
print(os.environ["ODBCINI"])
print(os.environ["OASDK_ODBC_HOME"])
Before reboot:
[2020-07-27 18:46:51,948] {logging_mixin.py:112} INFO - ('64bit', 'ELF')
[2020-07-27 18:46:51,949] {logging_mixin.py:112} INFO - ['ODBC Drivers', 'NetSuite ODBC Drivers 8.1']
[2020-07-27 18:46:51,950] {logging_mixin.py:112} INFO - {'NetSuite': '/opt/netsuite/odbcclient/lib64/ivoa27.so', 'ODBC': ''}
[2020-07-27 18:46:51,950] {logging_mixin.py:112} INFO - Error: 'LD_LIBRARY_PATH'
After reboot:
[2020-07-28 06:11:59,961] {logging_mixin.py:112} INFO - ('64bit', 'ELF')
[2020-07-28 06:11:59,963] {logging_mixin.py:112} INFO - ['ODBC Drivers', 'NetSuite ODBC Drivers 8.1']
[2020-07-28 06:11:59,965] {logging_mixin.py:112} INFO - {'NetSuite': '/opt/netsuite/odbcclient/lib64/ivoa27.so', 'ODBC': ''}
[2020-07-28 06:11:59,965] {logging_mixin.py:112} INFO - /opt/netsuite/odbcclient/lib64
[2020-07-28 06:11:59,965] {logging_mixin.py:112} INFO - /opt/netsuite/odbcclient/odbc64.ini
[2020-07-28 06:11:59,965] {logging_mixin.py:112} INFO - /opt/netsuite/odbcclient/lib64

freebsd ignores service startup

I installed 3proxy on freebsd(11.2-RELEASE-p10-HBSD FreeBSD ) which is whith opnsense from ports, but I cannot autoload it after restart
service 3proxy start - works nice
I make /usr/local/etc/rc.d/3proxy
-rwxr-xr-x 1 root wheel 653 Feb 26 20:35 3proxy
#!/bin/sh
# $FreeBSD: head/net/3proxy/files/3proxy.in 340872 2014-01-24 00:14:07Z mat $
# PROVIDE: threeproxy
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
# Define these threeproxy_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/threeproxy
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
threeproxy_enable=${threeproxy_enable-"NO"}
threeproxy_flags=${threeproxy_flags-"/usr/local/etc/3proxy.cfg"}
. /etc/rc.subr
name="threeproxy"
rcvar=threeproxy_enable
command="/usr/local/bin/3proxy"
load_rc_config $name
start_cmd="echo \"Starting ${name}.\"; ${command} ${threeproxy_flags} &"
run_rc_command "$1"
then added line here /etc/rc.conf
threeproxy_enable="YES"
But after restart I also see that service is down - how can I do this?
I also thought about crontab and #reboot.
Please help me

How to suppress any output from child process created with fork / exec

From within a test case (ActionDispatch::IntegrationTest) i have to fire up a rails server instance.
This is the code that starts the rails server:
##rails_server_proc = fork do
Signal.trap("QUIT") { puts "Killing rails server"; exit }
$stdout = nil
exec("rails s -e test --port #{##port}", [:out, :err] => "/dev/null")
end
Process.detach(##rails_server_proc)
That works fine, but I couldn't find a way to suppress the rails server's STDOUT.
The [:out, :err] => "/dev/null" has no effect, I am still getting the server output in my test output like this:
Booting Thin
=> Rails 3.2.11 application starting in test on http://0.0.0.0:3002
=> Call with -d to detach
=> Ctrl-C to shutdown server
...
Any ideas?
Try:
exec("rails s -e test --port #{##port} >/dev/null 2>&1")

How to resolve sqlplus conflicts?

I am install Oracle Instant Client: Basic, SDK and SQL*Plus packages v 12.1.0.1 for gem "ruby-oci8" than i realize that i need use Oracle Instant Client v 10.2.0.4. But whan i try to install rpm -ivh oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm i have error:
Preparing... ########################################### [100%]
file /usr/bin/sqlplus from install of oracle-instantclient-sqlplus-10.2.0.4-1.i386 conflicts with file from package oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.i386
How to resolve this issue?
You are trying to have two different versions of Oracle client libs (10g and 12c).
You can use:
replace -i with -U (U stands for upgrade)
remove ver. 10 first (rpm -e)
If you insist on having two differt client versions remove .rpm packages. And use .zip packges. And simply unpack them into /opt
ldd sqlplus
linux-gate.so.1 => (0x006bf000)
libsqlplus.so => /usr/lib/oracle/10.2.0.4/client/lib/libsqlplus.so (0x00110000)
libclntsh.so.10.1 => /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so.10.1 (0x006c0000)
libnnz10.so => /usr/lib/oracle/10.2.0.4/client/lib/libnnz10.so (0x00218000)
libdl.so.2 => /lib/libdl.so.2 (0x001c4000)
libm.so.6 => /lib/libm.so.6 (0x001c9000)
libpthread.so.0 => /lib/libpthread.so.0 (0x0041e000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00439000)
libc.so.6 => /lib/libc.so.6 (0x00469000)
/lib/ld-linux.so.2 (0x001f8000)
and ldd libclntsh.so
ldd: ./libclntsh.so: No such file or directory

whenever gem: I set :output but the logfile doesn't show up where I'd expect it to

In my schedule.rb file I have the following lines:
set :output, '/log/cron_log.log'
every 5.minutes do
command 'echo "hello"'
end
I ran whenever -w as suggested in this question Rails, using whenever gem in development, and I assume the cronfile is written and running. (I tried restarting the Rails server as well.)
And when I run $ crontab -l I see the following:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash
-l -c 'echo "hello" >> /log/cron_log.log 2>&1'
But I can't find the log file. I checked in rails_project/log, ~/log and /log to no avail. On OSX btw.
How can I get the log file to be written to the rails project log folder?
Where is your log?
You're putting the output file at the highest directory level:
$ cd /log
To see if the file exists and if it has data in it:
$ ls -la cron_log.log
To create the log file if needed:
$ touch cron_log.log
To open up permissions for your own local debugging (do NOT do this in production!)
$ chmod +rw cron_log.log
Is your command running?
To run the command manually to find out if it works as you expect:
$ /bin/bash -l -c 'echo "hello" >> /log/cron_log.log 2>&1'
To improve your security and protect your path, use full paths:
wrong: command 'echo "hello"'
right: command '/bin/echo "hello"'
To find the command full path:
$ which echo
To verify the cron is running as you expect:
$ sudo grep CRON /var/log/syslog
The grep result should have lines that something like this:
Jan 1 12:00:00 example.com CRON[123]: (root) CMD (... your command here ...)
Are you on a Mac?
If you're not seeing output in the syslog, and you're on a Mac, you may want to read about the Mac OSX switching from cron to launchd.
See the cron plist (/System/Library/LaunchDaemons/com.vix.cron.plist) and use a stdout/stderr path to debug cron itself. I don't recall if launchctl unloading and launchctl loading the plist is sufficient, or since it's a system daemon if you'd have to restart entirely. (see where is the cron log file in lion)
How to log relative to Rails?
To put the log relative to a Rails app, omit the leading slash (and typically call it cron.log)
set :output, "log/cron.log"
To put the log in a specific fully-qualified directory:
set :output, '/abc/def/ghi/log/cron.log'
The Whenever wiki has some good examples about redirecting output:
https://github.com/javan/whenever/wiki/Output-redirection-aka-logging-your-cron-jobs
Examples:
every 3.hours do
runner "MyModel.some_process", :output => 'cron.log'
rake "my:rake:task", :output => {:error => 'error.log', :standard => 'cron.log'}
command "/usr/bin/cmd"
end

Resources