[erlang-questions] Running an erl program on a remote machine

Edmond Begumisa ebegumisa@REDACTED
Tue May 24 00:13:06 CEST 2011


An alternative: You could make use of the OTP SSH Application...

* Have mirror start an Erlang daemon that does nothing but run the OTP SSH  
application (an empty dumb server.) The SSH OTP Application gives you a  
secure shell from which you can remotely run Erlang commands from an  
ordinary SSH client.

* From machinex, using any SSH client, send each mirror the script you  
want to run. You could type it in as expressions or use the SFTP subsystem  
of the OTP SSH application to push an escript.

* This script should tell the mirror...
1. How it should determine if it is THE_CURRENT_MACHINE,
2. What DB commands it should run if it does and when

* The mirrors are now no longer dependent on machinex being alive.

* When you need to change the script, SSH again into the mirrors, send the  
new scripts.

DOWN-SIDE: You'll have Erlang emulator process always running on the  
mirrors (but it won't be doing anything most of the time, so you probably  
need not worry about wasting resources.)

UP-SIDE: You'll have Erlang daemons on each mirror that you can remotely  
turn into anything you want whenever you want.

- Edmond -

On Tue, 24 May 2011 00:55:42 +1000, <phiroc@REDACTED> wrote:

>
> Hi,
>
> I have been asked to write a script which runs database commands on one  
> of n
> mirror machines. The name of the machine the commands should be run on is
> contained in a DNS alias called, say, THE_CURRENT_MACHINE. In other  
> words,
> if the THE_CURRENT_MACHINE alias resolves to machineA.company.com,
>  then the script should be run on that machine, if it resolves to
>  machineB.company.com, it should run on machine b, etc.
>
> I have thought of several ways of doing the above:
>
> - run a PERL script at a set time each day on a machine which I will call
> machinex, which resolves the THE_CURRENT_MACHINE alias, connects to
> it via SSH and runs the database commands. The disadvantage of
> this solution is that, if machinex is down, the PERL script won't be run.
>
> - run a PERL script at a set time each day on machines A and B (and C  
> and D...)
> makes sure that the current machine's name is equal to  
> THE_CURRENT_MACHINE value,
> and, if that is the case, runs the database commands.
> The disadvantage of this solution is that if I have 10 machines, I
> must duplicate the script on those ten machines.
>
> - write an Erlang program which create a remote process on  
> THE_CURRENT_MACHINE that
> runs the database commands, if it is feasible. Once again, if machinex  
> is down,
> the program won't be run.
>
> - write an Erlang script which will run as a daemon on machines A, B,  
> C...
> which checks every second if the time matches the time at which the  
> database
> commands should be triggered, and, if that is the case, run them.
>
> If I had never heard of Erlang and of its alleged "spawn a remote  
> process" capabilities,
> I would opt for solution 2 above. If you fellows have a better solution,  
> please let me know.
>
> Philippe
>
>
>
>
> ----- Mail Original -----
> De: "Carlo Bertoldi" <carlo.bertoldi@REDACTED>
> À: erlang-questions@REDACTED
> Envoyé: Lundi 23 Mai 2011 16:20:24 GMT +01:00 Amsterdam / Berlin / Berne  
> / Rome / Stockholm / Vienne
> Objet: Re: [erlang-questions] Running an erl program on a remote machine
>
> On 23/05/2011 16:12, phiroc@REDACTED wrote:
>> Hello,
>>
>> is it possible to run an erlang program on a remote machine without  
>> using the erl console?
>>
>> For instance, let's say that I have written a program that runs a batch  
>> script and that I would like to run it on machine B at a set time. Can  
>> I create an entry in my machine's crontab which runs the following  
>> script:
>>
>> erl -name machineB -detached<the name of the erl script that runs the  
>> batch script>
>>
> Why would you want to do that?
> Why not put that command directly in B's crontab?
>
>   Carlo
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



More information about the erlang-questions mailing list