• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

HOWTO Run a java chatserver application as a service under LINUX

Hello,

I have managed to create a chat server java application. It works fine, when i start it on the command line. However, when i close my ssh session it closes down ofcourse. I would like
to have this program running forever ( as a service or something else ) and dont want to stay logged in all the time.

Is there an easy way to do this ? I'm average experienced on windows platforms but am a novice on LINUX.

Hope someone can point me out or refer me to a tutorial that covers this clearly.

Thanks!

Marcel
0
marcel42
Asked:
marcel42
  • 5
  • 3
  • 2
  • +3
3 Solutions
 
girionisCommented:
Try to start it by using: java <your class> &
0
 
girionisCommented:
Alternatively you can put the above command on your .bashrc or .bash_profile and have it start automatically upon computer/shell start up.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
marcel42Author Commented:
Ok thanks, do you know how to close down this service again ? Just kill it with the kill command ? Or is there a cleaner method ?
0
 
TimYatesCommented:
http://wrapper.tanukisoftware.org/doc/english/introduction.html

Is a wrapper to allow your application to run as either a Windows service, or a UNIX Daemon :-)

Tim
0
 
girionisCommented:
> Ok thanks, do you know how to close down this service again ? Just kill
> it with the kill command ? Or is there a cleaner method ?

How do you stop it normally?

Kill would do. Alternatively you could write a script that sends a signal to it in order to stop, something similar to how the Tomcat start/stop is done.
0
 
petmagdyCommented:
u can search for the Java proccess and kill it by the Id
0
 
TimYatesCommented:
>  Try to start it by using: java <your class> &

This would still be killed when you logged out (I think)

A more stable version of this would be:

nohup java yourclass & > /tmp/nohup.out

the "nohup" tells the process no to die when you log off (and it gets sent a SIG_INT command to shut down)

I *think* ;-)
0
 
TimYatesCommented:
Also, I don't think .bashrc is read until you log in, so I am not sure that the process would start when the computer powered up...

(Oh, and SIG_INT in my previous comment should be SIG_HUP obviously) ;-)

Basically, you will either want to write a script to put in /etc/rc.d/init.d/ to allow /sbin/service to start, stop and restart your service, or use that wrapper from tanukisoftware (which is probably easier to use -- init.d scripts make my brain melt sometimes :-(
0
 
girionisCommented:
I think you are right about the "nohup"
0
 
CEHJCommented:
Tim's last comments are the ones you need
0
 
girionisCommented:
:)
0
 
zzynxSoftware engineerCommented:
Thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now