Biggeveen Posted November 22, 2010 Report Share Posted November 22, 2010 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... Quote Link to comment
Francois Normandin Posted November 22, 2010 Report Share Posted November 22, 2010 I've used FireDaemon Lite in the past (suggestion read in a KB article on ni.com a few years ago), but the company has changed its software offering and it doesn't seem to be free anymore. The Pro version is not very expensive (49$) and that works with Server 2008 and Win7. Quote Link to comment
ShaunR Posted November 22, 2010 Report Share Posted November 22, 2010 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) Quote Link to comment
Biggeveen Posted November 22, 2010 Author Report Share Posted November 22, 2010 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... Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.