Linux Users

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic App Startup

Hi all,

I have an application developed in LabVIEW 2009 and built into a stand-alone that uses NI-VISA. The application runs on openSUSE 11.1; NI-KAL version is 1.10. When I boot the computer and start the application manually, everything works fine. When I configure the system to start the application on startup (through Sessions), I see the following: the application briefly starts and disappears within a fraction of a second. Then I decided that maybe the application starts before some vital service starts, so now instead of starting the app directly, I start it through a script that has two lines:

sleep 10

/home/myappfolder/myapp

where myapp is the name of my application (I added the script to the autostart list in Sessions). This seems to work most of the time, but not always. I looked at the system log and found the following lines:

Nov  5 13:39:16 linux-v8dc myapp: [libnipalu.so.2.4]  Warning: source/lib/linux/linLoadKern.cpp:168 - libKernelDriverLoad: Failed to open nipalk, errno: 2

Nov  5 13:39:16 linux-v8dc myapp: [libnipalu.so.2.4]  Warning: source/initcln/initcln.cpp:147 - Posix: Init kInitClnPackage: kernelDriver: failed! status=-50204

Nov  5 13:39:16 linux-v8dc myapp: [libnipalu.so.2.4]  Warning: source/package/posix/ulibEntry.cpp:199 - initialize: unable to load NI-PAL. status=-50204

Should I just bite the bullet and increase the sleep time or is there a better way to autostart a LabVIEW/NI-VISA application on Linux?

Thanks,

Sergey L.

0 Kudos
Message 1 of 6
(5,823 Views)

I don't know what "Sessions" are, but you need to make sure that your programs starts after the "nipal" init script (/etc/init.d/nipal).  If you can add a dependancy on that service it should be more reliable than increasing your sleep time.

--

Shawn

Use NI products on Linux? Come join the NI Linux Users Community
0 Kudos
Message 2 of 6
(4,164 Views)

If you are using KDE for your desktop (the default in SUSE 11.1), then you can place your script in the ~/.kde4/Autostart folder and your program will launch when the user is first logged in. I use that feature all of the time with LabVIEW.

Randy Hoskin

LabVIEW for Linux

0 Kudos
Message 3 of 6
(4,164 Views)

Under Gnome, you can go to the Control Center and select Sessions.  Select the Startup Programs tab.  From there you can add a command to be issued whenever the user logs in and begins a gnome session.  I don't believe this will work if you want it to start at boot and I think it is user specific.

0 Kudos
Message 4 of 6
(4,164 Views)

Thanks for all responses. I am using Gnome; I used Control Center -> Sessions to add my program to the startup list. Unfortunately the Sessions interface does not allow you to specify dependencies for your program.

The output of "ps -A" command shows several NI-like entries: nimdnsResponder, niLxiDiscovery and nipalps. It looks like I should modify my startup script so that instead of

sleep 10

/home/myappfolder/myapp

it does something like this:

<wait until nipalps starts with some timeout>

<if not timed out, start  /home/myappfolder/myapp>

Does this make sense? If it does, any hints on how to write such a script would be greatly appreciated - I am a Linux newbie.

BTW I don't understand the following: I would think that NIPAL starts at boot, while my application starts as a user session. Shouldn't all boot processes start first, before any user processes?

Thanks a lot,

Sergey

0 Kudos
Message 5 of 6
(4,164 Views)

For those interested, here's a script that checks for NIPALK before launching the application and logs the outcome to a log file. This script is added to startup programs (in GNOME, that would be Sessions). If NIPALK does not start within timeout, the script displays an error dialog using Zenity (it is also possible to display a progress bar, but I don't do it here). In the example below, the user name is "tux" and the program is called "myapp". You may have to change permissions on the script file.

Regards,

Sergey

#!/bin/sh

i=0   # initialize iteration counter
tmo=40   # define timeout in seconds

# check if nipalk service started
while [ $i -lt $tmo ]
do
  if ps ax | grep -v grep | grep "cat /dev/nipalk" > /dev/null
  then
    break
  else
    sleep 1
  fi
  i=$[$i+1]
done

d=$(date)  # get date/time

if ps ax | grep -v grep | grep "cat /dev/nipalk" > /dev/null
then
  # append line to start log
  echo "$d: NIPALK service started within $i seconds" >> /home/tux/myappfolder/bin/myappstartlog
  # start application
  /home/tux/myappfolder/bin/myapp &
else
  # append line to start log
  echo "$d: NIPALK service failed to start within $i seconds"  >> /home/tux/myappfolder/bin/myappstartlog
  # display error message using zenity
  zenity --title "MyApp Initialization Error" --error --text "NIPALK service failed to start"
  # uncomment the next line to initiate system shutdown
  #/sbin/shutdown -h now &
fi

0 Kudos
Message 6 of 6
(4,164 Views)