Stupid windows services! Now what do I do?!

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

Stupid windows services! Now what do I do?!

Postposted on Fri May 14, 2004 12:37 am

I know there are about a hundred packages out there that install Folding@Home as a windows service for you.

Well I tried my own way, and its bugging the hell out of me cuz I cant figure out why its not working for me! I went ahead and used some other package to install F@H as a service, and technically it works fine.

It works, but personally I think installing services using intsrv.exe, netsrv.exe, and srvany.exe sucks. I prefer to use the SC command.


THIS IS WHAT I DID...

- I made a new folder D:\Folding@Home\
- I downloaded FAH4Console.exe into that folder.
- I placed 2 .bat files within that folder.
- install_service.bat
- delete_service.bat



install_service.bat
Code: Select all
@ECHO OFF

ECHO.
ECHO First, we'll configure Folding@Home's console.
ECHO.
pause

%cd%\FAH4Console.exe -local -configonly

ECHO.
ECHO.
ECHO Now we'll tell windows to...
ECHO 1) run Folding@Home as a service
ECHO 2) set the description for the service
ECHO 3) tell windows what to do if Folding@Home fails to start
ECHO 4) start the service and exit this window.
ECHO.
pause

sc create Folding@Home binpath= "%cd%\FAH4Console.exe -service -advmethods -forceSSE -forceasm -local -service -verbosity 9" start= auto displayname= Folding@Home
sc description Folding@Home "Folding@Home is a distributed computing project which studies protein folding, misfolding, aggregation, and related diseases. We use novel computational methods and large scale distributed computing, to simulate timescales thousands to millions of times longer than previously achieved. This has allowed us to simulate folding for the first time, and to now direct our approach to examine folding related disease."
sc failure Folding@Home reset= 100 actions= restart/60000/restart/90000/restart/120000
sc start Folding@Home
EXIT



delete_service.bat
Code: Select all
@ECHO OFF
sc stop Folding@Home
sc delete Folding@Home
EXIT





As far as it goes, everything's fine...until you tell it to actually start the service.
At that point, I keep getting Error 1053: The service did not respond to the start or control request in a timely fashion.


What do I do now?
<img src="http://gfx.statgfx.com/old/folding.cgi?&username=gubbar&teamid=2630&label=255,255,255&header=255,255,255&stats=255,255,255&trans=yes&template=techreport&.jpg&cpu=2">
gubbar924
Gerbil Team Leader
 
Posts: 265
Joined: Wed Feb 27, 2002 6:00 pm

Postposted on Fri May 14, 2004 8:31 am

anybody?
:(
gubbar924
Gerbil Team Leader
 
Posts: 265
Joined: Wed Feb 27, 2002 6:00 pm

Postposted on Fri May 14, 2004 8:41 am

What does this have to do with the Developer's Den, exactly?...
morphine
Gerbil Khan
Silver subscriber
 
 
Posts: 9860
Joined: Fri Dec 27, 2002 7:51 pm
Location: Portugal (that's next to Spain)

Postposted on Fri May 14, 2004 8:52 am

morphine wrote:What does this have to do with the Developer's Den, exactly?...
Batchfiles can easily be considered programming.
...
mattsteg
Gerbil God
 
Posts: 15752
Joined: Thu Dec 27, 2001 6:00 pm
Location: Applauding the new/old variable width forums

Postposted on Fri May 14, 2004 8:56 am

I'm pretty sure the reason it is not working is that the F@h client itself is not written to run as a Windows service. Windows services are special -- they need to respond to requests from the Service Manager. If the program does not respond to those requests, the error message you are getting is the result. "Normal" programs (like the F@h client) can be run as a service only if an additional "service wrapper" tool is used, to intercept and handle the requests from the Service Manager.

There are 3rd party service wrappers like Firedaemon... or if you are fluent in C++ programming (or just plain masochistic), I suppose you could write your own. But you can't just install the bare F@h client as a service with sc and expect it to work.
(this space intentionally left blank)
just brew it!
Administrator
Gold subscriber
 
 
Posts: 36897
Joined: Tue Aug 20, 2002 9:51 pm
Location: Somewhere, having a beer

Postposted on Fri May 14, 2004 9:58 am

Yeah, there's probably a reason why people generally use intsrv.exe, netsrv.exe, and srvany.exe, namely that they work.
...
mattsteg
Gerbil God
 
Posts: 15752
Joined: Thu Dec 27, 2001 6:00 pm
Location: Applauding the new/old variable width forums

Postposted on Fri May 14, 2004 10:23 am

1)
I wasnt sure which forum to put this post in, I just figured since it had to do with batch files and installing services it didnt really make much sense to put it in any other forum section except the one about windows...but I figured i would need some kind of programming help, so I posted it here

2)
damn it! wrapper my ass! :P when i ran FAH4Console.exe in a cmd window, I saw it calling fahcore_78.exe with a bunch of parameters. Obviously the parameters change for fahcore_78 as the parameters for fah4console change. Soooooo, I'll try just running fahcore_78 as a service instead.
(when I get home from work)
gubbar924
Gerbil Team Leader
 
Posts: 265
Joined: Wed Feb 27, 2002 6:00 pm

Postposted on Fri May 14, 2004 10:27 am

You can't just run the core as a service. First of all, it doesn't contain the code to communicate with the Windows Service Manager either, so you will get the same error message. Secondly, it is FAH4Console.exe that downloads the new WUs and uploads the results; if you run the core by itself (assuming it will even run at all without FAH4Console there), all it will do is finish crunching the current WU and exit.

If you want to run a non-service executable as a Windows service, you must use some sort of wrapper. Period, end of discussion.
(this space intentionally left blank)
just brew it!
Administrator
Gold subscriber
 
 
Posts: 36897
Joined: Tue Aug 20, 2002 9:51 pm
Location: Somewhere, having a beer

Postposted on Fri May 14, 2004 10:49 am

JBI is correct. Windows will not run any old EXE as a service, no matter what BAT file contortions you come up with. To be run as a service an executable has to conform to set of rules, including calling StartServiceCtrlDispatcher within 30 seconds of starting (the program you are running isn't doing that, which is why the error message says it didn't start in the required amount of time). Presumably the wrapper programs are of type SERVICE_WIN32_SHARE_PROCESS and know how to handle the various commands (if you look in the Services applet in Administrative tools you'll see that you can start and stop, and sometimes pause and resume, any service; anything that runs as a service has to written to handle that as well). It's entirely possible to write an application to function as both an ordinary console app and as a service, but presumably the app in question was not written that way. And in fact it would be better design to make it as a separate EXE or DLL and call it from a service, anyway, as that way you can also call it from a GUI app or even remotely. (I just got through doing exactly this with a .NET app)

But if you want to you could rewrite it as a service yourself. You'd want to start reading here.
UberGerbil
Gerbil Khan
 
Posts: 9927
Joined: Thu Jun 19, 2003 2:11 pm

Postposted on Fri May 14, 2004 11:33 am

:(


oh well, thanks for the feedback guys
gubbar924
Gerbil Team Leader
 
Posts: 265
Joined: Wed Feb 27, 2002 6:00 pm

Postposted on Fri May 14, 2004 12:36 pm

Just out of curiosity, why are you so opposed to using some sort of service wrapper?
(this space intentionally left blank)
just brew it!
Administrator
Gold subscriber
 
 
Posts: 36897
Joined: Tue Aug 20, 2002 9:51 pm
Location: Somewhere, having a beer

Postposted on Fri May 14, 2004 12:49 pm

just cuz they are wrappers...as opposed to a direct way of doing things.

i dunno, im just weird like that. I'd rather spend the time to learn how to do something the direct way, rather than (making it easier on myself and) having a middle man/layer/tier (whatever its called).

its hard to explain.
gubbar924
Gerbil Team Leader
 
Posts: 265
Joined: Wed Feb 27, 2002 6:00 pm

Postposted on Fri May 14, 2004 1:16 pm

gubbar924 wrote:just cuz they are wrappers...as opposed to a direct way of doing things.

i dunno, im just weird like that. I'd rather spend the time to learn how to do something the direct way, rather than (making it easier on myself and) having a middle man/layer/tier (whatever its called).

its hard to explain.

I think I understand where you're coming from. But in this case, it simply isn't feasible -- you either need to use a 3rd party wrapper, or write your own wrapper, per the instructions UberGerbil linked.

If you had the source code to FAH4Console.exe you could modify it to run as a service, eliminating the need for the wrapper. But AFAIK Stanford does not make source code for the client available.

Yes, eliminating unnecessary middle layers is generally a good thing; but eliminating necessary ones isn't! In this case, it is sort of like saying "I want to simplify my system by wiring the hard drive directly to the CPU chip, instead of going through the IDE controller on the chipset." Unless you've got the ability to design and fabricate your own CPU chip with an integrated IDE controller on it, you're not going to get very far.
(this space intentionally left blank)
just brew it!
Administrator
Gold subscriber
 
 
Posts: 36897
Joined: Tue Aug 20, 2002 9:51 pm
Location: Somewhere, having a beer


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 1 guest