Jump to content

Load shared variables from file at boot before log on


Recommended Posts

Dear all,

I've got a question regarding networked variables combined with Web Services, how to load these variables from a file at boot. I'm not sure if this is the right place as I'm new to Lava.

Our problem is the following, I hope some more experienced programmer can give me some hints in the right direction. Any help would be great.

The application consists of some RESTful web service vi's which are called using HTTP and a Labview management program. All this uses the same shared variables so they are of the type Network-published shared variable (see this thread). Some configuration is stored in the variables and this is edited using the Labview program. When a configuration change is made, the variables are written to an XML file, works ok. The web VI's read and write also to these variables but their values do not need to be saved when the machine is rebooted so they are not saved in XML.

The web service currently runs on LabVIEW 2010 on a Windows Server 2008 R2 system, finally the application should run using only the LV2010 runtime and NI web server.

What I want to do is read the XML at boot into the shared variables so I'm sure the configuration is read in correctly. I have a VI to do this. This initialization has to be done before the first HTTP call to a VI is made, so at boot time when the NI web server starts.

On Windows XP I could compile the initialization VI to a Labview exe and run it as a service using srvany.exe (tool from Microsoft), no problem. However in Windows 7 and Windows Server 2008 srvany.exe has gone.

Does anybody have an idea how to create a Labview exe which is compatible with windows services, and can be installed using sc.exe? By putting the load VI in the service exe the initialization problem would be solved.

As far as I know a service exe needs to response to certain start / stop / reload calls issued by the service manager.

One other solution is to make the web VIs check if the configuration is loaded and else execute the initialization VI, but this is - with about 10 web VIs - a bit a dirty solution...

Any ideas would be welcome...

Link to comment

I on't think you can write service applications in LV.

But sc.exe serves the same purpose as srvany.exe.

Go to a command prompt and type in

sc.exe create myservice binpath=pathtomyservice DisplayName="mydisplayname"

(of course change myxxxxx with the appropriate names and paths)

Link to comment

Well, seems srvany.exe does work on Windows Server 2008 R2 although it is not designed for it. I copied srvany.exe and instsrv.exe from the Windows XP box. I didn't try sc.exe jet because I had srvany.exe ready with some GUI to call it.

By the way, the srvany and our variable initialisation exe are 32-bit apps on a 64-bit Server 2008 R2, seems not to give problems (we don't need >2GB of memory jet and development is currently on Windows XP 32-bit system).

The only thing is that requests like sc stop (probably equal to undeploying the variables) and sc pause are not handled currently, srvany simply kills the labview exe. This is something to be solved. Also srvany is not supported by Microsoft (on any OS), which is a disadvantage too. Switching to sc.exe or similar is to be considered.

Kuan Chen wrote a guide how to create a Labview service (link one, two and three). It involves some C code and DLL stuff I'm not familiar with, note this was written in 2005 so maybe things changed...

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.