How to stop server (hg serve) ?

View: New views
10 Messages — Rating Filter:   Alert me  

How to stop server (hg serve) ?

by Alexander Schatten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am occasionally using hg serve; however I found no way to terminate the server.

If I start it in foreground, I can terminate the shell, which stops the server (OS X, btw). But when I start it with

hg serve -d

in demon mode, there seems to be no way to stop the server without rebooting or killing the job from the terminal; but I could not find the job (unfortunately there are a lot of jobs running in OS X...)

So to conclude: is there a reason, why there is no

hg serve --stop

or

hg serve --shutdown

command?


thanks!


Alex
_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by Yann E. MORIN :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alexander.
All,

On Sunday 01 November 2009 21:56:14 Alexander Schatten wrote:
> I am occasionally using hg serve; however I found no way to terminate the server.

I've put up a small utility for this:
http://ymorin.is-a-geek.org/hg/mercurial/hgutils/

Run with "hgserver help" to get some help.

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
`------------------------------^-------^------------------^--------------------'


_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by Benoit Boissinot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Nov 01, 2009 at 09:56:14PM +0100, Alexander Schatten wrote:

> I am occasionally using hg serve; however I found no way to terminate
> the server.
>
> If I start it in foreground, I can terminate the shell, which stops
> the server (OS X, btw). But when I start it with
>
> hg serve -d
>
> in demon mode, there seems to be no way to stop the server without
> rebooting or killing the job from the terminal; but I could not find
> the job (unfortunately there are a lot of jobs running in OS X...)

I think the right way is to use --pid-file and kill `cat /path/to/pid`.

>
> So to conclude: is there a reason, why there is no
>
> hg serve --stop
>
> or
>
> hg serve --shutdown
>
> command?

I don't think there is a standard place to place the pid file, that's
why. (it could be in /var/something but it usually isn't user writable
anyway).

regards,

Benoit

--
:wq
_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by Isaac Jurado :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Replying Alexander Schatten:

>
> So to conclude: is there a reason, why there is no
>
> hg serve --stop
>
> or
>
> hg serve --shutdown
>
> command?

Because in UNIX you have signals that already do the job.  And OSX is
UNIX too.  Somebody else has mentioned the --pid-file.  You can also try
with (in a shell):

    ps xu | fgrep -i hg | awk '{print $2}'

To get the daemon PID (e.g. 4938), and then send a termination signal:

    kill 4938

_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by Alexander Schatten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the hint

the --pid-file option seems not to work under OS X. I tried it out, but the process is alway called "Python"... Not ideal.

However, by such reasons, in my opinion, it is a rather strange concept for a server to rely on underlying OS functions for "shutdown". Think of servers like Tomcat; there should be, at least in my opinion, always a command to start and stop.

thanks


Alex

-------- Original-Nachricht --------
> Datum: Mon, 2 Nov 2009 00:18:13 +0100
> Von: Benoit Boissinot <benoit.boissinot@...>
> An: Alexander Schatten <ml_alexanderschatten@...>
> CC: mercurial@...
> Betreff: Re: How to stop server (hg serve) ?

> On Sun, Nov 01, 2009 at 09:56:14PM +0100, Alexander Schatten wrote:
> > I am occasionally using hg serve; however I found no way to terminate
> > the server.
> >
> > If I start it in foreground, I can terminate the shell, which stops
> > the server (OS X, btw). But when I start it with
> >
> > hg serve -d
> >
> > in demon mode, there seems to be no way to stop the server without
> > rebooting or killing the job from the terminal; but I could not find
> > the job (unfortunately there are a lot of jobs running in OS X...)
>
> I think the right way is to use --pid-file and kill `cat /path/to/pid`.
>
> >
> > So to conclude: is there a reason, why there is no
> >
> > hg serve --stop
> >
> > or
> >
> > hg serve --shutdown
> >
> > command?
>
> I don't think there is a standard place to place the pid file, that's
> why. (it could be in /var/something but it usually isn't user writable
> anyway).
>
> regards,
>
> Benoit
>
> --
> :wq
_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by Christian Ebert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Alexander Schatten on Monday, November 02, 2009 at 11:28:37 +0100
> the --pid-file option seems not to work under OS X. I tried it
> out, but the process is alway called "Python"... Not ideal.

$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.5.8
BuildVersion: 9L30
$ hg serve --pid-file test.pid &
[1] 5417
$ cat test.pid
5417
$ kill -9 `cat test.pid`
[1]+  Killed                  hg serve --pid-file test.pid

c
--
  Was heißt hier Dogma, ich bin Underdogma!
[ What the hell do you mean dogma, I am underdogma. ]

_F R E E_  _V I D E O S_  --->>> http://www.blacktrash.org/underdogma/
_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by Alexander Schatten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, this works indeed.

I did check the Mac OS UI Activity Log (I have a German OS here, I am not sure what the English name is, Germin is "Aktivitätsanzeige").

And there is always just indicates "Python". This is what I meant, and it was probably a misunderstanding.

However, I still believe, that this is a rather inelegant solution.

thanks for the help



Alex

-------- Original-Nachricht --------
> Datum: Mon, 2 Nov 2009 12:34:31 +0100
> Von: Christian Ebert <blacktrash@...>
> An: mercurial@...
> Betreff: Re: How to stop server (hg serve) ?

> * Alexander Schatten on Monday, November 02, 2009 at 11:28:37 +0100
> > the --pid-file option seems not to work under OS X. I tried it
> > out, but the process is alway called "Python"... Not ideal.
>
> $ sw_vers
> ProductName: Mac OS X
> ProductVersion: 10.5.8
> BuildVersion: 9L30
> $ hg serve --pid-file test.pid &
> [1] 5417
> $ cat test.pid
> 5417
> $ kill -9 `cat test.pid`
> [1]+  Killed                  hg serve --pid-file test.pid
>
> c
> --
>   Was heißt hier Dogma, ich bin Underdogma!
> [ What the hell do you mean dogma, I am underdogma. ]
>
> _F R E E_  _V I D E O S_  --->>> http://www.blacktrash.org/underdogma/
> _______________________________________________
> Mercurial mailing list
> Mercurial@...
> http://selenic.com/mailman/listinfo/mercurial
_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by Greg Ward-17 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 2, 2009 at 6:34 AM, Christian Ebert <blacktrash@...> wrote:

> $ sw_vers
> ProductName:    Mac OS X
> ProductVersion: 10.5.8
> BuildVersion:   9L30
> $ hg serve --pid-file test.pid &
> [1] 5417
> $ cat test.pid
> 5417
> $ kill -9 `cat test.pid`
> [1]+  Killed                  hg serve --pid-file test.pid

I'm glad the pid file works on OS X, but you really shouldn't use
"kill -9" as a first resort.  And explaining it like this will make
newbies think that "kill -9" is the right thing to do.  In general,
it's not.

Consider a server that maintains data structures on disk.  A
well-written server will intercept signals (eg. Ctrl-C or vanilla
"kill" (SIGTERM)) and shut itself down in a orderly fashion.
Transactions will be aborted or committed as appropriate, locks will
be released, etc.

However, SIGKILL (aka kill -9) cannot be intercepted by the process
being killed.  That's the whole point of it.  So if you "kill -9" a
well-behaved server, you are making it impossible for it to shutdown
cleanly (abort transactions, release locks, etc.).  That leaves a mess
for the next user of those data structures to deal with.

The usual way to shutdown a server process on Unix is to send it a
SIGTERM (kill <pid>).  If it is still running after a few seconds,
*then* you pull out the big guns and send SIGKILL (kill -9 <pid>).

Greg

_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by Christian Ebert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Greg Ward on Monday, November 02, 2009 at 09:44:28 -0500

> On Mon, Nov 2, 2009 at 6:34 AM, Christian Ebert <blacktrash@...> wrote:
>> $ sw_vers
>> ProductName:    Mac OS X
>> ProductVersion: 10.5.8
>> BuildVersion:   9L30
>> $ hg serve --pid-file test.pid &
>> [1] 5417
>> $ cat test.pid
>> 5417
>> $ kill -9 `cat test.pid`
>> [1]+  Killed                  hg serve --pid-file test.pid
>
> I'm glad the pid file works on OS X, but you really shouldn't use
> "kill -9" as a first resort.  And explaining it like this will make
> newbies think that "kill -9" is the right thing to do.  In general,
> it's not.
>
> Consider a server that maintains data structures on disk.  A
> well-written server will intercept signals (eg. Ctrl-C or vanilla
> "kill" (SIGTERM)) and shut itself down in a orderly fashion.
> Transactions will be aborted or committed as appropriate, locks will
> be released, etc.
>
> However, SIGKILL (aka kill -9) cannot be intercepted by the process
> being killed.  That's the whole point of it.  So if you "kill -9" a
> well-behaved server, you are making it impossible for it to shutdown
> cleanly (abort transactions, release locks, etc.).  That leaves a mess
> for the next user of those data structures to deal with.
>
> The usual way to shutdown a server process on Unix is to send it a
> SIGTERM (kill <pid>).  If it is still running after a few seconds,
> *then* you pull out the big guns and send SIGKILL (kill -9 <pid>).

You are right of course. I was tempted by the immediate output of
kill -9 which sort of proved that --pid-file works.

c
--
Wer auf sein Elend tritt, steht höher.
_HÖLDERLIN: H Y P E R I O N_  --->> http://www.blacktrash.org/hyperion/
_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial

Re: How to stop server (hg serve) ?

by TK Soh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Nov 1, 2009 at 11:18 PM, Benoit Boissinot
<benoit.boissinot@...> wrote:

> On Sun, Nov 01, 2009 at 09:56:14PM +0100, Alexander Schatten wrote:
>> I am occasionally using hg serve; however I found no way to terminate
>> the server.
>>
>> If I start it in foreground, I can terminate the shell, which stops
>> the server (OS X, btw). But when I start it with
>>
>> hg serve -d
>>
>> in demon mode, there seems to be no way to stop the server without
>> rebooting or killing the job from the terminal; but I could not find
>> the job (unfortunately there are a lot of jobs running in OS X...)
>
> I think the right way is to use --pid-file and kill `cat /path/to/pid`.

VNC provides a -kill option to handle the termination of a VNC
session. Basically it's doing a kill on pid, but I always feel eerie
about the kill commands.

>>
>> So to conclude: is there a reason, why there is no
>>
>> hg serve --stop
>>
>> or
>>
>> hg serve --shutdown
>>
>> command?
>
> I don't think there is a standard place to place the pid file, that's
> why. (it could be in /var/something but it usually isn't user writable
> anyway).

Again to borrow some idea from VNC. VNC maintain the pid files in
user's $HOME/.vnc directory.

> regards,
>
> Benoit
>
> --
> :wq
> _______________________________________________
> Mercurial mailing list
> Mercurial@...
> http://selenic.com/mailman/listinfo/mercurial
>
_______________________________________________
Mercurial mailing list
Mercurial@...
http://selenic.com/mailman/listinfo/mercurial