LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-23-2009, 01:13 AM   #1
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Rep: Reputation: 0
inittab


hi,
Following is my coding in inittab
Code:
########
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

########
wa2:345:respawn:/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8002 >> /var/log/htsserver8002.log
How can i restart initab?
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 :-)
 
Old 09-23-2009, 02:36 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,397

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
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.
 
Old 09-23-2009, 03:05 AM   #3
mjsurette
Member
 
Registered: May 2005
Distribution: aptosid
Posts: 55

Rep: Reputation: 18
Quote:
Originally Posted by allensim81 View Post
hi,
Following is my coding in inittab
Code:
########
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

########
wa2:345:respawn:/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8002 >> /var/log/htsserver8002.log
How can i restart initab?
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 :-)
The command to reread inittab is 'kill -HUP 1'. It must be done as root. That part's easy, but it's not the solution to your problem.

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

Last edited by mjsurette; 09-23-2009 at 03:10 AM.
 
Old 09-23-2009, 03:28 AM   #4
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
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
 
Old 09-23-2009, 04:44 AM   #5
mjsurette
Member
 
Registered: May 2005
Distribution: aptosid
Posts: 55

Rep: Reputation: 18
Quote:
Originally Posted by allensim81 View Post
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
Sorry about that. I was talking about a totally different package.

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
 
Old 09-23-2009, 11:43 PM   #6
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 09-24-2009, 12:36 AM   #7
mjsurette
Member
 
Registered: May 2005
Distribution: aptosid
Posts: 55

Rep: Reputation: 18
Quote:
Originally Posted by allensim81 View Post
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.
No, the way inittab works is each process is independent, so they will both be running. You could still go from one to the other whenever one dies. Is there some particular reason that you don't want them both running at once? If so, you can write a shell script which calls one, then the other in an endless loop. Remember though, the second one won't start up until the first one exits, so you'll have gained nothing timewise.

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
 
Old 09-24-2009, 01:28 AM   #8
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
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
 
Old 09-24-2009, 02:01 AM   #9
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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.
 
Old 09-24-2009, 02:02 AM   #10
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,446
Blog Entries: 11

Rep: Reputation: 182Reputation: 182
Heres a sample shell script that should suit your needs

Code:
while [ 1 ]; do
 /usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8000 >> /var/log/htsserver8000.log
 /usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8001 >> /var/log/htsserver8001.log
done
put this into a shell script and call it from /etc/init.d/rc.local or just put the shell script into /etc/init.d and link to it from the apropriate runlevel init directory.
 
Old 09-24-2009, 03:45 AM   #11
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
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
 
Old 09-24-2009, 03:57 AM   #12
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 09-24-2009, 04:25 AM   #13
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,446
Blog Entries: 11

Rep: Reputation: 182Reputation: 182
Quote:
Originally Posted by allensim81 View Post
hi zhjim,1 more querries,
to put he above shell script izzit samething as i add on the following at inittab?
Jup it just resambles what you did inside the inittab. It works like this. Loop for ever (while [ 1 ]) then start the first server on port 8000. When the programm ends the next line is called and the second server is started on port 8001. Then start all over (loop for ever).
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:
Originally Posted by allensim81 View Post
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.
The automation is the loop for ever

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
use 9000 as a port just to make sure the port is not in use.
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
 
Old 09-24-2009, 10:12 PM   #14
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
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 :-)
 
Old 09-25-2009, 02:49 AM   #15
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
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. :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
since we have no /etc/inittab scrupul0us Ubuntu 19 12-09-2010 04:54 PM
About /etc/inittab zaxonus Linux - General 3 06-04-2007 06:01 AM
rc[0-6] and inittab kpachopoulos Linux - General 1 08-12-2005 04:27 PM
inittab mikedeatworld Linux - Software 3 08-13-2004 10:01 AM
Cant get out of inittab InEeDhElPlInUx Linux - Newbie 3 10-09-2003 02:13 PM


All times are GMT -5. The time now is 07:07 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration