inittab
hi,
Following is my coding in inittab Code:
######## can i have 3 post as above... once port 8000 is died, either port 8001 or port 8002 will be invoked. How to do do this? Do i need to write a simple script.. please help and guide me. Appreciate your help :-) |
why are you doing this in inittab?? This seems to be a massive misuse of the functionality it provides. I think you need a proper service script instead.
|
Quote:
respawn is just what it sounds like. It starts a process and waits for it to return. When it does, it immediately restarts it. A quick look at the code for htsserver shows that it forks into the background and returns immediately. This is normal for servers, but will not mesh well with respawn. If you want to hack the code and remove the call to daemonize() in main, that will stop it from returning immediately, but even then you shouldn't put it in inittab. Init processes run as root, which is one reason why you won't find servers in inittab. Too big of a security risk. Anyone hacking your server totally owns your system. This is one reason why you will not find servers started in inittab. A more secure way would be to hack it so that it doesn't return immediately and write a script calling it in an endless loop. Run this script as a normal user which has been set up specifically for this purpose. I assume that the reason you have to do this is the server keeps crashing. If so then all this will become unnecessary once the code stabilizes. Good luck Mike |
Hi, the reason I doing is this is beacuse:
Iam using Webhttrack and everytime I finish to configure a project in web mode with htsserver, the server stops (with the message "Unable to create the server: No such file or directory). Is it possible to restart the htsserver server automatically or to reuse the current port 8000 ? It is imposible to restart the htsserver in the same port during few minutes because it's seems that is not really stopped. Please guide me on this. I really dont have any ideas to solve this. Thanks |
Quote:
I loaded the right package, tried it, and got exactly what you got. A couple of things I noticed: You can specify the port it listens on at startup. htsserver --port 8081 /path/to/html/root/dir The error message only shows up after you click on the Finsh button. At that point all files have been downloaded, so it's a non-issue as far as downloading is concerned. You'll want to notify the authors so they can fix this though. Hope that helps, Mike |
Hi Mike,
Thanks for your fast reply! Appreciate it! Now that i open 2 ports in /etc/initab, port 8000 and port 8001 as following: ######## wa1:345:respawn:/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8000 >> /var/log/htsserver8000.log ######## wa2:345:respawn:/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8001 >> /var/log/htsserver8001.log Can it be like when port 8000 is being used and after the user finished download the website and click on the exit button, port 8000 will stop/die, but then immediately port 8001 will be called to replace port 8000, vice versa. Can this be done? do i need to write a simple script for this? or this can be done by just few lines of command in inittab? Please guide me on this... Thanks a lot. |
Quote:
This is not the proper way to start servers though. It's the wrong way to do this from both an administrative and security point of view. Don't forget this is a wide open server running as root. That sets off so many alarms for me that it makes my head hurt. I hope for your sake that you're at least hidden behind a NAT router. Mike |
Hi Mike,
U r awsome! u are really fast! I want both porth running at once. What i mean in my previous post is that,whenever user finish download the website by using Webhttrack and click exit button, the htsserver seems like dies, and everythg stop. I dont want this to happen, so, i am thinking of how to automatically avoke port 8001 when 8000 is dead. So that user can continue to use Webhttrack to download the website again.. without to wait for longer time. Can this be done? can u guide me, thanks my logic is : if port 8000 die, then port 8001 quickly been called & cont to fucntion if port 8001 die, then port 8000 quickly been called & cont to fucntion |
The port 'dies' because it's not closed properly in the software. So although the application does no longer run, the lower layers (network stack?) are still listening on the used port.
This should basically be fixed at the application level, not by creating a workaround. |
Heres a sample shell script that should suit your needs
Code:
while [ 1 ]; do |
dear zhjim,
cool zhjim! i tired to put the shell script at the /etc/init.d Once i run it at the terminal to start it, it shows: Unable to initialaize a temporary server (no remaining port) can u please guide me on this. thanks in advance |
hi zhjim,1 more querries,
to put he above shell script izzit samething as i add on the following at inittab? ######## wa1:345:respawn:/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8000 >> /var/log/htsserver8000.log ######## wa2:345:respawn:/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8001 >> /var/log/htsserver8001.log Can it be automate? if port 8000 die,it will go straight to port 80001,without user key in the port. Thanks & Appreciate your help. |
Quote:
Keep in mind that this only works if the start up of the server remains in forgeground. Else the script tries to start a programm that uses a already in use port. Quote:
The error message you get from script points to a port allready in use problem. Please see what happens when you just run this line from the terminal Code:
/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 9000 >> /var/log/htsserver9000.log If it puts you back on the command line imediatly the program acts like a daemon. Meaning it puts itself into background. If this is the case see if there is a option to have the program run in foreground. May when you read up on this things will get a bit clearer for you http://www.yolinux.com/TUTORIALS/Lin...itProcess.html Cheers Zhjim |
Thanks for the fast reply.
now that two ports are working, if one die, another one will still working. But then the user need to key in the port by themself.Let say if http://10.17.32.46:8000/server/index.html die, user need to type the url to http://10.17.32.46:8001/server/index.html. My question..can it be like when http://10.17.32.46:8000/server/index.html die, it will automatically route to http://10.17.32.46:8001/server/index.html without user key in anything? How can this be done... issit i need to do it on my html ? Please advice, appreciate your help! Thanks in advance :-) |
Hi,
I am stil wondering how to solve this: Now that Once user finished download using ths url: http://10.17.32.46:8000/server/index.html the htsserver will die, so in order to let user continue to use the application, http://10.17.32.46:8001/server/index.html must be avoke. How can these be done? should i wirte a script to do this or should i write some coding in my html? pls advice.Appreciate ur guidiance and help. :-) |
All times are GMT -5. The time now is 03:39 PM. |