Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
restart erlang app service - kills rest of running code
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Wes James  
View profile  
 More options Oct 20 2011, 12:41 pm
From: Wes James <compte...@gmail.com>
Date: Thu, 20 Oct 2011 10:41:27 -0600
Local: Thurs, Oct 20 2011 12:41 pm
Subject: [erlang-questions] restart erlang app service - kills rest of running code
I put an erlang VM on a win 7 workstation as a service:

erlsrv add "0esvc" -stopaction "init:stop()." -name node@host -w
"C:/erldir" -args "-setcookie CHOCOLATECHIP -kernel
inet_dist_listen_min 11111 -s my_app"

I then send a message from my mac to the windows workstation:

my_app:do_send(net_restart,node@host).

and it gets to this point:

case Com of
        net_restart ->
            os:cmd("net stop 0esvc"),

% but then everything stops after the above line - the next line is
not reached since the erlang VM has been stopped.

            os:cmd("net start 0esvc");

I could write a script 0esvc.cmd with

net stop 0esvc
net start 0esvc

instead and call os:cmd("0esvc.cmd");

but is there a way to restart the 0esvc from erlang?

For now I have a second simple service 2esvc that I can send a command
and it restarts the 0esvc.

How about if I write an erlang script that has

timer:sleep(5000),
os:cmd("net start 0esvc");

And I call it:

net_restart ->
    os:cmd("escript restart.erl"),
    os:cmd("net stop 0esvc"),

But then the escript call will block the process from continuing until
os:cmd is done - is there a way to spawn that call off so it can run
later?  But to be spawned the VM needs to be running.

Maybe 0esvc.cmd is the best way to do this.

Why am I restarting the VM?  If I update the code in my_app,
restarting will update it.  I guess, I could just not worry about the
restart and when code is updated, just restart the workstation (one of
50 in a student computer lab).

thanks,

-wes
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Cottlehuber  
View profile  
 More options Oct 20 2011, 2:57 pm
From: Dave Cottlehuber <d...@muse.net.nz>
Date: Thu, 20 Oct 2011 20:57:42 +0200
Local: Thurs, Oct 20 2011 2:57 pm
Subject: Re: [erlang-questions] restart erlang app service - kills rest of running code
On 20 October 2011 18:41, Wes James <compte...@gmail.com> wrote:

> I put an erlang VM on a win 7 workstation as a service:

> erlsrv add "0esvc" -stopaction "init:stop()." -name node@host -w
> "C:/erldir" -args "-setcookie CHOCOLATECHIP -kernel
> inet_dist_listen_min 11111 -s my_app"

I don't think stopaction is needed. The vm receives windows service
control messages and responds to them just fine.

> I then send a message from my mac to the windows workstation:

> my_app:do_send(net_restart,node@host).

> and it gets to this point:

> case Com of
>        net_restart ->
>            os:cmd("net stop 0esvc"),

> % but then everything stops after the above line - the next line is
> not reached since the erlang VM has been stopped.

Not surprising considering net.exe tells the OS to stop the VM. Were
you expecting the code to keep running even though the VM is stopped?

>            os:cmd("net start 0esvc");

> I could write a script 0esvc.cmd with

> net stop 0esvc
> net start 0esvc

> instead and call os:cmd("0esvc.cmd");

> but is there a way to restart the 0esvc from erlang?

Why not call init:restart() which does exactly what you need, from
inside the VM?

Would erlang's hot code loading allow you to avoid needing to restart
the VM at all in your case?

Finally consider setting the service parameters to auto-restart with:

-onfail restart_always

in your erlsrv service creation.

A+
Dave
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes James  
View profile  
 More options Oct 20 2011, 3:30 pm
From: Wes James <compte...@gmail.com>
Date: Thu, 20 Oct 2011 13:30:03 -0600
Local: Thurs, Oct 20 2011 3:30 pm
Subject: Re: [erlang-questions] restart erlang app service - kills rest of running code
Hi.

On Thu, Oct 20, 2011 at 12:57 PM, Dave Cottlehuber <d...@muse.net.nz> wrote:
> On 20 October 2011 18:41, Wes James <compte...@gmail.com> wrote:

<snip>

>> but is there a way to restart the 0esvc from erlang?

> Why not call init:restart() which does exactly what you need, from

Thank you - that is what I needed.  Ran the code, made a change in the
code, set the message to run that command in place of the other two I
had there and the the new changes showed up!

> inside the VM?

>Would erlang's hot code loading allow you to avoid needing to restart
>the VM at all in your case?

I could do hot code loading.  Maybe I'll look in to that later, but
the above works as I need it for now.

<snip>

Thanks again, Dave!

-wes
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »