2

I'm developping a webservice with golang. It uses the net/http package and others packages like github.com/go-sql-driver/mysql and redigo (redis). I have no problem when I develop it, no bugs. When I put it on a server in production as a service in back ground (i.e. : launched with ./myProgram &). The problem is that after a few times, which is never the same : it can be a few minutes or a few hours, it just crash. The service doesn't appear anymore in netstat : it is down. I look the memory/CPU consumption/opened tcp connections, there's nothing anormal. I also log information on errors and requests on my service in a file, but there is nothing anormal, it just crashes.

If you have any idea,please tell me. Or any idea on the way I can track the error.

GuillaumeP
  • 504
  • 5
  • 19
  • 3
    It may be giving you an error message, but you would have no way of seeing it as you aren't piping the output anywhere. If you start it with `nohup ./myProgram &` it will run in the background but put all of the output in the file `nohup.out`, and then once it crashed you could look at the file and see if there is an error message. – dave Jul 07 '15 at 16:32
  • 1
    Obviously no one here is going to be able to debug your webservice for you and obviously you have a bug which is resulting in a fatal panic (no recover)... Find your way to a specific programming problem and you'll surely find help but there's not much to do here. As far as catching your error goes, you can use a defer/recover pattern to implement what acts like an application level exception handler (catch block). Then log your error and use that information to write an actual question. – evanmcdonnal Jul 07 '15 at 16:32

1 Answers1

2

You mention that this only happens when running on a production server.

Could it be the case that the process is being killed when you disconnect your login session? If so, you want to either use a proper startup script, or at least start it with nohup

nohup ./myProgram &

See this answer at serverfault for more details.

Community
  • 1
  • 1
Colin Nicholson
  • 1,331
  • 12
  • 18