Windows exe fork

52 views
Skip to first unread message

Bill N

unread,
May 30, 2014, 12:27:08 PM5/30/14
to puppet...@googlegroups.com
Hi,

Just wrote my first puppet module for Windows  provisioning. All is working well except I am having a problem running a windows exe file in that Puppet appears to wait for the exe to complete. At least this is the case when I run Puppet agent --test from the Windows Server command line.

What I want to do here is install a set of files for a Riemann monitoring client on several Windows Server 2008 R1 VMs. These files include an exe, which I want to start and run in perpetuity. I don't want Puppet to wait for this process to complete. It appears I could run the exe in a separate shell using cmd.exe, but when I try that on the command line I do not see the named process running in the Resource Monitor. I only see cmd.exe running. This is not very informative.

My question is, what is the best way to run this executable via Puppet? Should I convert the exe to a Windows service, install that and run it as a service? Should I use shell cmd and live with the unhelpful Resource Monitor listing? Or should I use Power Shell to fork the process like I would in linux?

Any help would be most appreciated.  

Jim Ficarra

unread,
Jun 1, 2014, 9:49:32 PM6/1/14
to puppet...@googlegroups.com
I’m not familiar with how the Reimann monitoring client runs – but if you run it at the command line and it runs within the shell and requires the command shell to run perpetually, you could try “start.exe reimannclient.exe” or whatever the name of the exe is.  There are a # of command line switches that you can look at in the help by typing start /? at the command line.  This would be a kludgey way to do it though to be honest.  You won’t have a very good way to control it.
 
Alternatively, it’s usually better to run these types of things within the service control manager as a service if they are supported which will give you more control over starting, stopping, and ensuring it starts up when the servers reboot, etc.  Hopefully your tool is able to run natively as a service.  if not, you can try to set up a service wrapper to run it as a service (Unfortunately you can’t just convert any exe natively into a Windows service).  SrvAny (the wrapper) and InstSrv (sets up the SrvAny wrapper in the registry/service control manager) were tools available in the Windows 2003 Server Resource Kit.  I’ve recently read that those 2003 tools still work in 2008, but keep in mind that they are not supported and your mileage may vary.
 
If your client is available as something that can run as a service that would be much better.
 
You could use puppet to ensure the components are installed properly and that the service is set to run all the time. 
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/c5d75b7c-531d-40d2-a027-f118910206af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bill N

unread,
Jun 2, 2014, 9:31:53 AM6/2/14
to puppet...@googlegroups.com
Jim,

Thank you for your advise. I have access to the C# source code so I can rebuild this as a service in VS2012. I should have realized this from the start but I confess I was trying to cut corners by using what I had readily available. 

best regards,

-Bill

Rob Reynolds

unread,
Jun 2, 2014, 1:38:18 PM6/2/14
to puppet...@googlegroups.com
If you don't want puppet to control the start and stop and want it to continue running after puppet is done, a service would be best. There are other methods of calling it to run as a service from the command line and having it continue running but if you have access to the source code, then I would definitely recommend a service.

When you start an executable, it will still be running in the task manager even if called from cmd.exe, although it might be hard to find. I suggest looking at SysInternal's Process Explorer as a replacement for task manager.



For more options, visit https://groups.google.com/d/optout.



--
Rob Reynolds
Developer, Puppet Labs

Join us at PuppetConf 2014September 20-24 in San Francisco
Register by June 5th to take advantage of the Early Adopter discount save $349!

Reply all
Reply to author
Forward
0 new messages