PDA

View Full Version : Dual Processor/service question



goffenhiemer
05-08-2002, 01:59 PM
I want to run DF on a system with 2 processors as a service. I need to run 2 sevices, one for each processor. I have copied the directory twice but it won't let me create the service twice. Has anyone done this?

KWSN_Millennium2001Guy
05-08-2002, 02:10 PM
http://bane.free-dc.org/forum/showthread.php3?s=&threadid=576

Not supported yet. :(

I could add 21 more processors if this was supported.

I have heard that http://www.firedaemon.com/ provides a program that will allow you to do this, but I can't put that program on my servers.

goffenhiemer
05-08-2002, 02:39 PM
Thanks for the quick response. I don't want to mess with Fire Daemon either. I have had problems with it in the past. I will just run one instance as a service and the other the regular way until they come up with a solution.

Scoofy12
05-09-2002, 01:32 AM
you could run one as a service and the other as a screen saver to look pretty :)

Brian the Fist
05-09-2002, 11:53 AM
To remind you, the problem is that the name of the service must be hard-coded into the executable. The executable needs to know the name of the service immediately when it begins. Passing it as a command line argument will not work (because services are called by the OS, without arguments :mad: ) I cannot think of a way to do this without providing two separate executables with two different hard-coded service names (which for obvious reasons is not a good solution). If someone can think of a good way around this, please let us know.

Digital Parasite
05-09-2002, 12:48 PM
Hi Howard,

When I wrote the service code for the ECC challenge that is currently going on (http://www.nd.edu/~cmonico/eccp109/software.html) when you do an add service call as you said you have to provide a name for the service and multiple services cannot have the same name.

What you could do is add another switch to your program which calls similar service add code but with a different name. So instead of just having /install you could have /install and /install2, etc... Your program could parse the /install look for a number and just tack that onto the name of the service you are using like "DistributedFolding" for the first "DistributedFolding2" for the second, etc... It should work fine, it did for my code.

I can provide some C++ code examples of how I did it if you like.

In the past did the CASP expiry dates for predictions have a wide difference from each other ie: some expire weeks/months after others?

Since the target list is currently being created/posted and the DistributedFolding project is only working on the first protein in Phase 1b, are we going to start working on the CASP5 proteins as soon as they are available or are you going to wait predicting how long it will take to compute so we can do as much of the earlier phases as possible first?

Thanks,
Jeff.

Brian the Fist
05-10-2002, 11:22 AM
We will start CASP as soon as we are ready and interrupt the 'normal' phases as needed. As for the service, adding /install2 is not good enough. Because how will the executable know that the name of the service is now different? Do you see what I mean? /install2 would have to somehow modify the executable so it knows its service name has changed. Maybe there's still a way around this though?

Digital Parasite
05-10-2002, 12:20 PM
Maybe I'm missing something but you would have to run the DistributedFolding code from two different directories correct so it wouldn't mess up the output files and other information if you want to run two on the same machine?

You can do this by having two copies of the same executable. You put the first copy in C:\df1 and the second in C:\df2

Go to C:\df1 and run foldtrajlite /install and it will install it as a service named whatever (I'm not sure what you are calling it) say "DistributedFolding", it is set to AutoStart and points to C:\df1\foldtrajlite.exe or whatever with a working directory I'm assuming of C:\df1

Now, you go to C:\df2 where you have the second copy of the same executable and now you run foldtrajlite /install2 and it will install it as a service named "DistributedFolding2" so that names will not be the same, but this time points to C:\df2\foldtrajlite.exe with a working directory of C:\df2

Now the second one will start automatically from the second C:\df2 directory and be completely separate from the first, each one sending in results and working independently.

The executable doesn't need to know the name of the service, it is Windows which calls and run the executable listed in the Service configuration you create. If you name it something different for the second one and point it to a different directory, it will call the correct one.

Like I said before, I have done this with C++ for another distributed computing project and can provide the source code to show you how if you are interested.

If you still don't understand than I am not explaining myself properly because it can be done, I have done it.

Here is a C++ code snippet:

// Get the executable file path so you are pointing to correct one
::GetModuleFileName(NULL, szFilePath, sizeof(szFilePath));

// Create the service
hService = ::CreateService(hSCM, m_szServiceName, m_szServiceName, SERVICE_ALL_ACCESS | SERVICE_PAUSE_CONTINUE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, szFilePath, NULL, NULL, NULL, NULL, NULL);

So here m_szServiceName is a string for the name of the service you want to register like "DistributedFolding" or "DistributedFolding2" and the szFilePath is the path to the correct directory so one could be "c:\df1" and the other could be "c:\df2" or whatever the user chooses.

Regards,
Jeff.

Brian the Fist
05-12-2002, 03:52 PM
well, in service_main in my code (the part that presumble gets called when the service starts up), among other things, I make a call to

sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME), service_ctrl);

Where SZSERVICENAME is the name of the service, which like I said is currently hard-coded. I am not certain what this does but I think it is needed, no? So if I had two copies of the same EXE in different directories, they'd both try to reguster the same service name because they wouldn't know that one is DistribFold1 and one is Distribfold2 or whatever. If you know a way to avoid calling this I think that is all that was holding me back..

MAD-ness
05-13-2002, 12:22 AM
/me crosses fingers....

Digital Parasite
05-13-2002, 01:42 PM
Originally posted by Brian the Fist
well, in service_main in my code (the part that presumble gets called when the service starts up), among other things, I make a call to

sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME), service_ctrl);

Where SZSERVICENAME is the name of the service, which like I said is currently hard-coded. I am not certain what this does but I think it is needed, no? So if I had two copies of the same EXE in different directories, they'd both try to reguster the same service name because they wouldn't know that one is DistribFold1 and one is Distribfold2 or whatever. If you know a way to avoid calling this I think that is all that was holding me back..

You can do several things. You can create a .ini file or some config file when you install the service that records the name of the service. So if you do a /install and the default name is "Distributed Folding" it records that to the conf file, if you did a /install2 and the new name is "Distributed Folding2" it records that to the conf file. Then when the service is started the code first reads the conf file and sets SZSERVICENAME to whatever the appropriate name is.

The control handler doesn't seem to affect starting and stopping the service, ie: you don't need it to if everything works fine but where I think it matters if if you are trying to intercept signals from the service system like PAUSE and ERROR messages. If you use the config file method you should be fine since you will have the proper service name.

The way may test program is setup (you can have the code if you want) it has a default hard-coded SZSERVICENAME name which is uses for creating/removing the service. If you just have one client on a machine it works great. If you want to do a /install2 it will use another name to create/remove the service. When the service is started it will check to see if the default SZSERVICENAME is present (which it is in this case since both are installed at the same time) and then launch the proper second service. I don't know if any errors would affect this or not. Your best bet is to probably do the .ini/conf file thing.