code formating

Wednesday, February 17, 2010

Live, evolution and computational programs

I just came up with a quote that I think it´s cool. Well, to be honest I haven´t done the research to see wether someone else has came up with it already. The Post it´s open to comments if so but I´ll give it a shot:

Life can be described as an evolving network of computational programs, in which the consciousness of our own minds it´s just a side effect.

To come up with it, I have been greatly influenced by my computer science background, Alan Kay and this post by Richard P. Feynman.

Friday, February 5, 2010

For gods sake Windows! just want a daemon!

Today I found myself trying to run an Erlang detached process on a Windows box. I copied all the files to the server, wrote a very simple batch file and ... yep, Erlang was running in the background!

I then logged out and came back to my cubicle and tried to ping the node. There was no way I could talk to it. Back to the server, I noticed that the Erlang detached process wasn't running any more.

So, here is the first conclusion: When you log out, Windows kills all the processes started by the user that was logged in. I asked the admin guy and he told me to set a task to call the batch file. This would allow me to avoid having to log in to launch the process.

That indeed solved the problem but how do you schedule the task? If you set it to start on every machine startup, the process might die or be killed and the process wouldn't be restarted until the machine is rebooted.

If you schedule it periodically, and the process hasn´t died, the second time around, the batch will crash when calling the erl command with the same "sname". Erlang will then write a crash dump file. The process that is already running will continue to run but it is not an elegant way to do it.

The "a little bit better" solution that I came up with was to run the following scrip:
tasklist /FI "IMAGENAME eq erl.exe" 2>NUL | find /I /N "erl.exe">NUL
if "%ERRORLEVEL%"=="0" goto :END
cd "aplicaciones\erlang\"
"C:/Archivos de programa/erl5.7.2/bin/erlc.exe" batz_server_app.erl bs_sup.erl bs_server.erl batz_server.erl bs_time_server.erl epsilon.erl email.erl gros97.erl
"C:/Archivos de programa/erl5.7.2/bin/erl" -boot start_sasl -sname b1 -setcookie einw -s batz_server -detached

It runs an Erlang process only if an erl.exe process is not already running on that machine.We can now call this batch periodically without worrying whether the node is already up or not.

Note that the batch would´t work right if we needed to have more than one Erlang node on the same machine.

So the second conclusion is that building standalone processes on Erlang to run on the background on a Windows machine is not the easiest thing.

Programatically walk a CATIA tree in .NET

One of the most basic tasks when automating anything in CATIA, it's usually to walk the whole tree and apply some changes to objects in ...