Page 1 of 1

bat file to restart renderservers?

Posted: Thu May 17, 2007 4:21 pm
by lllab
hi all, does anybody know how to make a bat script for xinxp to restart a program (maxwell renderserver) on pcs on the network.

i imagine something like restart server on 192.168.1.xx.
is this doable, and how?:-)

with remote this is quite a task to restart all.

thanks for help
cheers
stefan

Posted: Fri May 18, 2007 1:40 pm
by ricardo
Hi,

With bat files I don't think it's possible.

I think it would be possible by installing http://www.cygwin.com/ on all the machines and enabling telnet service on the rendering nodes. I played with it once and it gives ps an kill.

A regular linux shell script would be able to log-on the render node, identify and kill the mxcl process and start another one. Some thought would be needed to avoid using clear text passwords on the script.

Ricardo

Posted: Fri May 18, 2007 8:15 pm
by lllab
hi thanks for answer,
well some vray guys in the chaos forum did that with bat files and ps-tools on windows. but i seems quite complicated and i couldt tranlate that for maxwell...

thanks anyway, guess i will have to do this by hand,
cheers
stefan

Posted: Fri May 18, 2007 11:06 pm
by michaelplogue
I know I would be able to do this using VBA in MS Access. In theory, it should be possible to translate this to VBScript, but I'd have to play around with it for a while. I've never really played with VBScript before, but it looks pretty much the same as VBA - just without any interface. I just don't know what sort of drain on processor time it would have since it would have a timer event constantly running.

If I have time this weekend, I'll play around with it to see if I can come up with something.

Posted: Fri May 18, 2007 11:53 pm
by michaelplogue
OK.... I've figured out how to do this in VB Script, I just need to do a bit more playing around to clean up the script a bit, and I'll post it here.

Posted: Sat May 19, 2007 1:49 am
by michaelplogue
OK..... Here's a VB script that you would install and run on every computer in your farm that is running Maxwell Server (MW-S). It has practically no processing footprint except when it detects that MW-S has been closed and needs to run it again. It uses around 10 MB of memory.

Right now it's pretty crude, and the only way to stop it from running is to kill the process from the Task Manager (wscript.exe). Plus, aside from it being listed in the Task Manager, there is nothing set up to give you a visual indicator that it is running.

What this script does is it detects when MS-S closes, and opens a new instance. Now the problem with this is that the NL programers used the same executable (mxcl.exe) to run the Renderer, Server, and Manager, so all three show up in the Task Manager as mxcl.exe. Since the Renderer will be run when the Server receives a job, and will close when it's done, the script detects this as a "closing" and will open up another instance of MR-S - something we don't want it to do.

So, in order for us to 'trick' the computer, what you first need to do is to copy the mxcl.exe file and name the copy mxcls.exe (keep it in the same directory). You will also need to modify the shortcut for running Maxwell Server so when you run it for the first time, it uses the mxcls.exe file instead of the original mxcl.exe. I'd put this shortcut into the startup folder so it runs at boot-up.

Now, copy the text between the lines below, paste it into notepad, and save the file to something like RestartMRServer.vbs (it can be anything as long as it has the vbs extention).

'---------------------------------------------------------------

Dim objShell
Dim MyProg
strComputer = "."

MyProg = "mxcls.exe -server -p:low"
Set objShell = CreateObject("WScript.Shell")

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
ExecNotificationQuery("select * from __instancedeletionevent " _
& " within 1 where TargetInstance isa 'Win32_Process'")

Do
Set objLatestProcess = colMonitoredProcesses.NextEvent
If lcase(objLatestProcess.TargetInstance.Name) = "mxcls.exe" Then
objShell.Run MyProg
End If
Loop

'---------------------------------------------------------------


Put this file on your desktop, or even your startup folder so it automatically runs when the computer is booted up. This will need to go on all computers in your render farm.

Now, every time MR-S closes on one of your computers, it will be re-initialized by the script.

NOTE: I've tested this by closing the server manually, and killing the process within the Task Manager. I don't know if it will work if MR-S crashes on it's own. It should, but since I'm not set up for network rendering yet, I can't really test it. I've tried this on Windows XP and XP 64 and it seems to work fine. This script was "MacGyver-ed" together using various examples I found on the net, so I can't take full credit...... :oops:

Hope this does the trick for you!

,

Posted: Sat May 19, 2007 2:45 pm
by lllab
wow thanks micheal!
i will try, i have to test it with the new version, there its abit different;-)

best greetings
stefan

Posted: Sat May 19, 2007 10:35 pm
by michaelplogue
No problem!

I'm currently working out a way to kill all instances of Maxwell Server and Maxwell Render, then re-initialize Maxwell Server on every system in the render farm from any computer in the network. I should hopefully have a solution by the end of the day. :wink:

Posted: Sun May 20, 2007 1:40 am
by lllab
"I'm currently working out a way to kill all instances of Maxwell Server and Maxwell Render, then re-initialize Maxwell Server on every system in the render farm from any computer in the network"

-- yes thats actually excatly what i am searching for too!

thanks again- i think some here will be very thanksfull:-)
cheers
stefan

Posted: Sun May 20, 2007 5:09 am
by michaelplogue
Here we go. What I've done is create two Visual Basic Scripts, both of which will run on every computer that's running Maxwell Server.

The first script - MW Server Monitor - will detect whenever Maxwell Server (MWS) closes, and opens up a new instance of it automatically.

The second Script - MW Network Monitor - will determine when all instances of MWS and Maxwell Render (MWR) need to be closed out. A total network purge of MWR & MWS can be done from any computer running this script.

There are several steps that need to be taken in order for this to work on your network.

STEP 1: On each computer you want to run MWS, you need to copy the mxcl.exe file and rename it mxcls.exe (keeping it in the same folder). You should also modify the shortcut used to open MWS to ensure this is the file always being used to run MWS (all you have to do is add the additional 's' to the mxcl.exe in the [Target] section of the shortcut).

The reason for this is because the same executable (mxcl.exe) is used to run the Renderer, Server, and Manager, so all three show up in the Task Manager as mxcl.exe. By having a copy named differently, the script will be able to differentiate between MWR & MWS.

STEP 2: You need to create a new folder somewhere on a shared, network drive. In my case, I created a [MaxwellServers] folder on my drive that holds all of my textures - all computers should be able to see this drive. Your path should look something like this:

\\Dualdual\Dualie Files\MaxwellServers\

This is the folder where you will place both scripts, so they can be run from all computers without having to copy them onto every single one manually. This folder is also used to hold some text files. I'll explain later what these text files do.

STEP 3: Now you need to extract the two scripts into the folder you created above. This would be a good time to go ahead and create shortcuts for both scripts, and a copy of the main MWS shortcut into your Startup folder on all of your render farm computers. this way, all three will start automatically when the system boots up. (The files can be downloaded from the link at the end)

STEP 4: Now, you will need to do a little editing of the scripts so they know where your new folder is located. You will need to do this step for both scripts.

First, right-click on one of the scripts and select Edit. This will open up the script in Notepad. Near the top you will see this line:

MyPath = "\\Dualdual\Dualie Files\MaxwellServers\"

You will need to put your full UNC path of the directory you created in step 2 in between the quotation marks (make sure you don't forget the end slash).

Save, Close, and repeat for the other script.

STEP 5: Now you are ready to test everything. On a couple of your computers, go ahead and run MWS (using your new shortcut) and the two scripts (double-clicking on them will get them going). On each computer, a couple of MSIE windows will pop up (see image below).

Image

Now, if you open up the shared folder you created, you will see a couple of text files there. Their file names should match the names of each computer that has these scripts running. If they are not there, or you get an error, you probably typed your UNC path incorrectly, or the folder/drive is not mapped on all of your computers.

If every thing is working correctly, whenever you close out MWS, another instance should open up.

Let me now explain what these text file are for. Whenever you run either of the scripts, it will look in this folder to see if there is a file named after the computer it's running on. If it's not there, it will create one. There's nothing in the file itself - It's the presence and the file name that is important. While the MW Network Monitor (MNM) is running, it is periodically checking to see if this file is still present. If it is not there, that is it's signal to close out every instance of MWR and MWS.

When you click on the [Kill All Network Processes] button, all of these text files are deleted from the shared folder. When each computer on your renderfarm detects that it's identifying file is no longer there, it will go through it's refresh subroutine. Even if you have a hundred instances of MWR or MWS, all will be shut down. From here, the MW Server Monitor will take over, and open up a new instance of MWS.

Overall, you will have around a 40 MB commit charge (between the scripts and the two instances of IE) against your memory. It will have practically no processor footprint, so all of that can be dedicated to the rendering process.

When version 1.5 is released, and if it's 64 bits, I'll have to re-test this to see if it still works. But I have tested this on XP and XP64 without any problems.

NOTE: When closing the two IE windows, you should always use the Close Monitor buttons. If you click on the X, the VB scripts will not be killed, and will still be listed in your Task Manager.

If you are using a single computer to do all of your work, and are not using it as a server, you only need to run the MW Network Monitor whenever you want to refresh you network. It does not need to be running all of the time.

Hopefully this will work for everyone. If anybody has any suggestions for improving these, please feel free to let me know.

The scripts can be downloaded from the link below.

http://www.divshare.com/download/686665-120

Enjoy! :wink:

.

Posted: Sun May 20, 2007 5:46 am
by michaelplogue
I forgot to mention: If you want to 'refresh' only one or several specific computers on your farm, all you have to do is delete their text files from the shared folder. Their MW Network Monitors will do the rest.

Posted: Sun May 20, 2007 11:57 pm
by lllab
wow michael-thank you very much!
this is great.

i am in middle of a job, but i will test with 1.5 soon:-)
cheers
stefan

Posted: Sat May 26, 2007 9:17 pm
by rendertaxi
michael,
is it possible for me to change your scripts to other network-render-based programs? do i only need to change paths and program names? it is concerning our cinema4d network modes which sometimes shut themselves down and want to be restarted automatically..
appreciate your effort!

cheers, alex

Posted: Sat May 26, 2007 9:40 pm
by michaelplogue
Sure rendertaxi. You should be able to use this with pretty much any network based program you are running on your farm. As I mentioned for maxwell, you just need to be careful if the same executable is being used for different tasks. In which case, copying and renaming it will fix that problem.

It could also be used to monitor multiple programs, but would require some more extensive scripting to work properly.

If you want to use this for just C4d, then you'd just need to change the variables for MyPath and MyProg. You may also want to to consider changing the extension of the text file to something like .C4 to avoid confusion in the future.

If you run into any problems, just give me a holler!

I'm currently working on a new set of scripts that will allow you to monitor Maxwell Server, or Fry Server, or both at the same time on your farm. This system will also include the capability of re-booting all of the computers in the farm (as long as the systems re-boot without requiring logging in).

My next step after this would be to include a status window that displays which computers are operational, what Renderer servers they are running, and to be able to specify what to run on each specific server (to include machine-specific re-booting). This will be a bit farther in the future, as I'm having to learn some new things along the way...... :wink:

Posted: Thu May 31, 2007 8:05 am
by lllab
"I'm currently working on a new set of scripts that will allow you to monitor Maxwell Server, or Fry Server"

great Micheal! this is a really very very helpful workflow tool!:-)
i also use both, happy you do that too:-)
cheers
stefan