respawn java process

James Pifer jep at obrien-pifer.com
Tue Apr 15 12:47:23 UTC 2008


I run a small java program called jredirect for forwarding a port. The
problem is after a while the process halts. I don't know why and there
aren't a lot of options, such as logging. 

It's run like this:
/usr/java/j2re1.4.2_03/bin/java -cp /usr/java/jredirect/jredirect.jar jredirect.Main --poolsize 50 host_ip:src_port-dst_ip:dst_port

So to forward 443 to a nonstandard port you could do:
/usr/java/j2re1.4.2_03/bin/java -cp /usr/java/jredirect/jredirect.jar jredirect.Main --poolsize 50 192.168.1.30:443-192.168.1.40:445

How could I set this up to respawn of the process goes away? 
AND
How quickly does something respawn? 


I've also tried to get port forwarding working with iptables, figuring
it would be more stable, but I could not get it to work. Even if I open
iptables wide open it doesn't work for me. Here are the commands I've
tried:

/sbin/iptables -t nat -A PREROUTING -p tcp -d 192.168.1.30 --dport 443 -j DNAT --to 192.168.1.40:445
/sbin/iptables -A FORWARD -p tcp -d 192.168.1.30 --dport 443 -j ACCEPT


The examples of forwarding I've seen usually include -i plus the
interface, like -i eth0. I do not have this in there because the address
I need it associated to is a virtual, so it's eth0:2 for example. After
running the commands above I can run iptables -L and it looks ok. 

Any suggestions or recommendations are appreciated. 

Thanks,
James




More information about the users mailing list