Page 1 of 1

Cleaning force exiting a render

Posted: Mon Oct 29, 2018 7:59 pm
by dkelly84
Hi,

I've pushed out CGRU to around 100-150 workstations with Blender, Houdini, Maya and Nuke - first of all can I just say thanks for such great software, we're having great fun making the most of our hardware with it.

I have configured a startup scheduled task to launch render.cmd (and therefor afrender) on boot up so it runs in the background, and have a script that kills the afrender process in the event of a user logging on to the workstations. Then when they log off, it starts back up again. All hosts are Windows 10.

It all works well, but I'm wondering if there's a cleaner way to stop the render? Killing the process and letting the zombie timeout mark the host offline does work, but it means the it becomes an error host for that job.

Can this be achieved with afcmd? or another way? I'm thinking that setting the host NIMBY and then ejecting all jobs would do the trick (and then setting as free again when the user logs off) would do it, but I'm not sure how to achieve this.

thanks in advance.

Re: Cleaning force exiting a render

Posted: Tue Oct 30, 2018 10:38 am
by timurhai
Hi.
You should ask afender to exit. Do not kill process.
On Linux to ask to application to quit we run kill ... command - it sends SIG_INT signal, to kill process we run kill -kill ... - it sends SIG_KILL.
Both on Windows and Linux, if we run application in a console, CTRL+C asks application to quit.
Also on Linux we have a script that runs afrender as a service, when we ask service to stop, script send SIG_INT signal.
I am not a Windows admin, but try to find a way to ask afrender to exit, SIG_INT signal, what CTRL+C does.

btw,
All soft that you listed, works on Linux perfectly! ))

Re: Cleaning force exiting a render

Posted: Tue Oct 30, 2018 12:34 pm
by dkelly84
Thanks, I will look into that.

Normally I would use something like taskkill /im "afrender.exe", which should work, but I'm getting a failure with reason:
"Reason: This process can only be terminated forcefully (with /F option)", so I've been using the /F to kill it.

I can see what you mean with regarding Ctrl+C terminating cleanly, I just need to be able to replicate that in script.

Unfortunately Linux isn't an option for us, or at the very least, the decision isn't mine.

Re: Cleaning force exiting a render

Posted: Tue Oct 30, 2018 1:01 pm
by timurhai
You can also ask server to exit render.
Action example is here:
https://github.com/CGRU/cgru/blob/maste ... nders.json

For exit action type should be

Code: Select all

"type" : "exit"

Re: Cleaning force exiting a render

Posted: Tue Oct 30, 2018 9:42 pm
by dkelly84
Thanks for your suggestions, I've managed to come up with a solution that lets afrender run constantly in the background.

In my batch file that either starts or stops afrender depending if someone is logged on, I've done the following:

Get the computer name in lowercase:

Code: Select all

for /f "usebackq delims=" %%I in (`powershell "\"%COMPUTERNAME%\".toLower()"`) do set "LOWERCOMPUTERNAME=%%~I"
When no one is logged on:

Code: Select all

%CGRU_LOCATION%\afanasy\bin\afcmd.exe type rfree %LOWERCOMPUTERNAME%
When someone logs on:

Code: Select all

%CGRU_LOCATION%\afanasy\bin\afcmd.exe type rNIMBY %LOWERCOMPUTERNAME%
%CGRU_LOCATION%\afanasy\bin\afcmd.exe type reject %LOWERCOMPUTERNAME%
That seems to handle things nicely.

Re: Cleaning force exiting a render

Posted: Wed Oct 31, 2018 9:17 am
by timurhai
Yes! This is the simplest way to ask server to exit render. I forgot about afcmd.
It sends JSON action object as i described above:
https://github.com/CGRU/cgru/blob/maste ... r.cpp#L206