aMule Forum

English => Feature requests => Topic started by: Vollstrecker on July 21, 2005, 02:36:46 PM

Title: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 21, 2005, 02:36:46 PM
Hi,
while playing around with amule and the posibillity to startup amuleweb automatically I saw, that amuleweb isn't shutdown when I close amule. Maybe it's because I had to kill amule, but after 5 tries I have 5 amuleweb processes. One for each try.
I would suggest, that either amule kills amuleweb at shutdown (or kill) or that amule checks if amuleweb is already running, and then don't start another instance.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: lfroen on July 21, 2005, 02:56:38 PM
That was an original idea, but implementation seems buggy ...
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Kry on July 21, 2005, 04:14:47 PM
Code: [Select]
// Kill amuleweb if running
if (webserver_pid) {
printf("Killing amuleweb instance...\n");
wxKillError rc;
wxKill(webserver_pid,wxSIGKILL, &rc);
printf("Killed!\n");
}

Maybe if you don't kill it... :P
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 21, 2005, 06:54:40 PM
I don't want to, but sometimes it is needed. I wanted to test how many downloads it can handle, and with atm 649 on an remote fs appear some errors. Sometimes I just have to, so it would be nice, if amule would check if amuleweb is already running.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Kry on July 21, 2005, 08:28:49 PM
And do what if it's running?
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 21, 2005, 08:45:16 PM
Quote
Code: [Select]
wxKill(webserver_pid,wxSIGKILL, &rc);
Why killing? Why not just terminating it? Doesn't wx have a wxSIGTERM?
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 21, 2005, 09:14:48 PM
Quote
Originally posted by Kry
And do what if it's running?

Nothing. When I killed the new ones, I can use the old one.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Kry on July 22, 2005, 03:12:52 PM
Nonsense. amuleweb connects to a running aMule, and DOESN'T reconnect to it if it's lost. So you can't use the old one with a newly running aMule.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 22, 2005, 04:00:13 PM
Maybe I killed the false one, but it should be no problem to reconnect. Or at the other side, you could let amuleweb die when it loses connection.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: ken on July 22, 2005, 11:30:20 PM
Well, certainly, it should quit if it loses the connection and it has no stdin.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 23, 2005, 12:42:23 AM
werner@Werner1:~$ ps -A | grep amule
12480 ?        00:00:00 amuleweb
werner@Werner1:~$
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Kry on July 23, 2005, 02:37:42 AM
Yeah, that did make a lot of sense.

Now, if you could explain what you pretend to achieve by that lines...
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 23, 2005, 03:29:59 PM
Quote
Originally posted by ken
Well, certainly, it should quit if it loses the connection and it has no stdin.

Quote
Originally posted by Vollstrecker
werner@Werner1:~$ ps -A | grep amule
12480 ? 00:00:00 amuleweb
werner@Werner1:~$
Quote
Originally posted by kry
Now, if you could explain what you pretend to achieve by that lines...


Got it now?
There is no amule or amuled process running, so it has lost connection. I closed the console where I started amule, so it has no stdin, stdout or stderr. But it does run.
Or was that wath ken posted not the behaviour? If that was a suggestion, I would be glad to see that implemented.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Kry on July 24, 2005, 02:30:27 AM
It was a sugestion.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: lfroen on July 24, 2005, 08:18:07 AM
Exit when connection is failed is wrong.
Instead, on every request from browser amuleweb must perform one more connection attempt. If succeded, return to normal operation; if not - display error page telling the nature of the problem, like "connection failed/timeout/no route to host/ etc".
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 24, 2005, 12:19:19 PM
Quote
perform one more connection attempt
wrong. Instead, it should check the "existing" connection, whether it is still connected, or not. I agree with the error page.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: lfroen on July 24, 2005, 03:09:45 PM
Quote
wrong. Instead, it should check the "existing" connection

No, that's wrong. Consider that your existing connection is dead (no matter reason), and you're not "still connected". Now what you do ? Silently exit ?!
You can check whether existing connection is still "alive" whatever it means, but be ready that it's not. And if it's not - you have to reconnect.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 24, 2005, 10:25:16 PM
Jep, and when you implemented that reconnect, amule can check if amulewb is already running, and then not starting a new one.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: lfroen on July 25, 2005, 08:36:14 AM
Quote
amule can check if amulewb is already running
I have serious doubt about this. How exactly do you check this without knowing pid upfront ? Not that this is impossible, but neither trivial.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 25, 2005, 09:30:04 AM
Quote
You can check whether existing connection is still "alive"
That was what I meant.

Quote
And if it's not - you have to reconnect.
nope, instead

Quote
if not - display error page
The error page might have an option to try to reconnect (option == a link)

Quote
Quote
amule can check if amulewb is already running
I have serious doubt about this. How exactly do you check this without knowing pid upfront ? Not that this is impossible, but neither trivial.
You can check whether amuleweb is running or not (not trivial, as lfroen said), but you'll never be able to find out whether this running webserver instance wanted to connect to you.

Just imagine, that you start amuleweb, that connects to amule somewhere else. Then you decide to run amule too on this local machine. Amule would find out that a webserver is running, so it wouldn't start another one, but now it should.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 25, 2005, 10:43:53 AM
You can check if you get an answer on webserver-port. 4711 I think. When you get an answer on this port, amuleweb is running. I don't think that it works if  you want to start a second one, on the same port, because the two amulewebs don't know to which of them you are talking. No matter if it wants to connect to you or not.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 25, 2005, 12:49:53 PM
Quote
You can check if you get an answer on webserver-port. 4711 I think.
Yes, it is the default port. But nothing keeps users from changing it, so...
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 25, 2005, 01:33:02 PM
When I see right, you can specify only the port where amule accepts EC, not the port amuleweb listens on commandline. So I think that port is in amule.conf or remote.conf. So amule can see which port he has to check.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 25, 2005, 02:49:54 PM
Quote
When I see right, you can specify only the port where amule accepts EC, not the port amuleweb listens on commandline.
From amuleweb man page:
Code: [Select]
      -s, --server-port=
              Webserver's HTTP port. This is the port you can point your browser to (default: 4711)
Quote
So I think that port is in amule.conf or remote.conf. So amule can see which port he has to check.
Well, remote.conf... which user? Amuleweb can be run by any user, not necessarily by the one who runs amule. The only requirement is that (s)he: 1) has an appropriate remote.conf file (or any other name, see the -f, --config-file command-line option), 2) supplies adequate command-line parameters, 3) answers the questions from amuleweb.

Actually, it could be implemented:
1) amule check for a process with a command name "amuleweb{DLG}"
2) check the command-line of the process for a -s switch
3) if not found, get the owner of the process
4) if owner of the process is not the current user, and we are not root, then give up
5) check the command-line of the process for a -f switch, if not found use "remote.conf" as config file name
6) read config file from the detected user's home directory.

I think it 1) doesn't wort the effort, 2) opens security holes, 3) people used to not like when a process just reads their secret files without a notice.

If you disagree with the above, just let me know :)

PS: And we still didn't care about things like:
1) what if a user renames amuleweb to something else, just for fun? (like amule-webserver, and leaves amuleweb as a symlink to the new name)
2) what if I use amuleweb to monitor another amule(d) somewhere else?
3) amuleweb behaves differently when started manually, manually with the -L switch, automatically...

So, certain cases can be detected, but it's more error-prone than useful.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 25, 2005, 03:05:04 PM
Another optoin would be, that amule sends a message to conected amuleweb-processes, that it terminates. Amuleweb can then terminate, too. Without the amule process where it is connected to it is useless, and if somebody complains about that, you could add an option to remote.conf that lets amuleweb be running.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 25, 2005, 03:20:19 PM
I also thought of it, but currently EC uses a polling mechanism (client ask something, core answers). No way to send a message from core to client. This would require rewriting EC sockets, etc (which will be done soon, so this might get implemented).

However, this is not a solution for situations when amule exits abnormally (i.e. crashes).
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: lfroen on July 25, 2005, 03:27:09 PM
Quote
Without the amule process where it is connected to it is useless

did you bothered to read thread above ?
If amule is unexpectedly quit - webserver should notify user about it. That's what it exist for - monitor remote amule.

Quote
Actually, it could be implemented:
1) amule check for a process with a command name "amuleweb{DLG}"
2) check the command-line of the process for a -s switch
3) if not found, get the owner of the process
4) if owner of the process is not the current user, and we are not root, then give up
5) check the command-line of the process for a -f switch, if not found use "remote.conf" as config file name

GonoszTopi: this is all over OS dependent. Even when available, you may not have permissions to access command line of other user's process. Consider situaltion when amuleweb started under other username.

But, let's stay focused. GonoszTopi - instead of trying to think about some imaginary scenario, where several amule's and amuleweb distributed over network and communicate with each other, let's make common case work correctly. And THEN think about exceptions.
Have you ever heard the word "usability" ?
The common case is "amuleweb" is started by amule (obviously on same machine) but amule(d) has quit unexpectedly. What we do ?

Quote
The error page might have an option to try to reconnect (option == a link)
You did not answered WHY it should be AN OPTION ? Why user would NOT want to reconnect ? Does (s)he enjoy looking in the error page ? Instead of including such link, just do it without bothering to ask user. This will provide match better experience.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: lfroen on July 25, 2005, 03:31:53 PM
Now, to the case of "amule set to start amuleweb automatically, but another one trying to reconnect". Obviously, both has been started with same options, and trying to listen on the same port. So, when amuleweb encountered situation that port can't be bound, it must simply quit, and we left with one amuleweb that reconnects and everything works as usual.
Even if user changed port in-between, nothing wrong happens - we will have 2 amuleweb's serving same page on 2 different ports.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 25, 2005, 03:41:44 PM
Quote
You did not answered WHY it should be AN OPTION ? Why user would NOT want to reconnect ? Does (s)he enjoy looking in the error page ? Instead of including such link, just do it without bothering to ask user. This will provide match better experience.
And did you think of HOW that "unexpectedly quit amule" gets restarted?

There should be an error page, that notifies user that something is wrong. Then the user can take appropriate steps (i.e. restart amule), and reconnect.

For being user-friendly, amuleweb can first try to reconnect and if that fails, only then displaying an error page (to deal with auto-restart scripts).
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 25, 2005, 03:43:30 PM
Quote
GonoszTopi: this is all over OS dependent. Even when available, you may not have permissions to access command line of other user's process. Consider situaltion when amuleweb started under other username.

But, let's stay focused. GonoszTopi - instead of trying to think about some imaginary scenario, where several amule's and amuleweb distributed over network and communicate with each other, let's make common case work correctly. And THEN think about exceptions.
Have you ever heard the word "usability" ?
describing difficulties and drawbacks != implementing

Quote
Consider situaltion when amuleweb started under other username.
see 4)
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 25, 2005, 05:20:07 PM
When amuleweb terminates, the user can see too that something went wrong. A page that tells you that something abnormal happend, or no page are the saem in this situation. You see something happend and have to look.
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: Vollstrecker on July 25, 2005, 11:35:14 PM
Quote
Originally posted by GonoszTopi
Quote
When I see right, you can specify only the port where amule accepts EC, not the port amuleweb listens on commandline.
From amuleweb man page:
Code: [Select]
      -s, --server-port=
              Webserver's HTTP port. This is the port you can point your browser to (default: 4711)

I double checked now. I see -s, but not what it means:

Werner1:/usr/src/amule/build/deb/cvs# amuleweb --help
Verwendung: amuleweb [--help] [-h ] [-p ] [-P ] [-f ] [-q] [-v] [-l ] [-w] [--create-config-from ] [--version] [-t ] [-s ] [-z] [-Z] [-A ] [-G ] [-a] [-d] [-L] [--amule-config-file ]
  --help                        Show this help text.
  -h, --host=              Host where aMule is running. (default: localhost)
  -p, --port=              aMule's port for External Connection. (default: 4712)
  -P, --password=          External Connection password.
  -f, --config-file=       Read configuration from file.
  -q, --quiet                   Do not print any output to stdout.
  -v, --verbose                 Be verbose - show also debug messages.
  -l, --locale=            Sets program locale (language).
  -w, --write-config            Write command line options to config file.
  --create-config-from=    Creates config file based on aMule's config file.
  --version                     Print program version.
  -t, --template=          Loads template
  -s, --sWerner1:/usr/src/amule/build/deb/cvs#
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: stefanero on July 26, 2005, 08:16:03 AM
ok
thats a error in the --help command, but gonszotopi also said MAN PAGE ;) reading helps :P
Title: Re: Auto startup of amuleweb should kill it at shutdown
Post by: GonoszTopi on July 26, 2005, 05:00:54 PM
wxCmdLineParser has some bugs in displaying help strings... hopefully it will be solved soon.