1

I'm running a FCGI spawn app on nginx on FreeBSD. It is buggy and I would like to analyse the .core file of the crash. But I don't have any clue where its generated. Does anyone know?

Zaibis
  • 69
  • 6

2 Answers2

3

First, your nginx has to be compiled with --with-debug configure option. If you're using freebsd ports you'd do add something like

CONFIGURE_ARGS+= --with-debug

To the Makefile in nginx's ports directory.

Then, in nginx.conf

worker_rlimit_core  2048M;
working_directory   /path/to/cores/;

in nginx.conf

and in /etc/sysctl.conf

kern.coredump=1
kern.corefile=/path/to/cores

(or "systctl -w kern-.coredump=1; sysctl kern.corefile=/path/to/cores")

Also make sure /etc/login.conf has appropriate permissions to generate cores for the user nginx runs as (typically a :coredumpsize=unlimited:, although you might want to restrict this). The nginx user will run under the "default" login class unless one is explicitly specified in /etc/master.passwd

quadruplebucky
  • 5,139
  • 20
  • 23
  • 1
    Although it's hard to tell, I think they are talking about the FCGI application crashing, not nginx. – sciurus Feb 20 '14 at 03:53
  • As he already sugested, not nginx is Crashing, My own FCGI app is crashing which gets served by nginx. But the point is, In the folder where the executed fcgi binary file no core file gets generated. And no where else I was able to find a config about core path or any fcgi related folder containing a core file. – Zaibis Feb 20 '14 at 06:42
  • If kern.coredump is other than 1, *nothing* will dump cores. If it's not the nginx core you're after, you may need additional configuration for whatever application is actually executing your CGI (the interpreter, I imagine), or maybe not - some (most) will do it on a segfault. – quadruplebucky Feb 20 '14 at 07:36
  • I said already that other applications do so. I checked already kern.coredump before and it is 1. As otherwise there wouldn't be a corefile generated by other programms. would it? – Zaibis Feb 20 '14 at 07:40
  • Maybe the dump it's trying to generate exceeds limits. Maybe it doesn't have write permission to where it's default location would be. I don't know, there are a lot of variables, I'm just suggesting some you definitely want to control. – quadruplebucky Feb 20 '14 at 07:53
  • Hmmm The folder the app is running in just has write permissions granted to root and group wheel. I thought that doesn't matter. Could that be the reason, as the fcgi app is run as user of group www? Is the User who is executing the one who technically writes the coredump file? – Zaibis Feb 20 '14 at 08:06
  • you generally don't want to grant write access to your webserver and subprocs to their own content directories, which is why you set kern.corefile to someplace persistent that doesn't matter (say, /var/tmp/cores) – quadruplebucky Feb 20 '14 at 08:14
  • Funny thing... My Website isn't crashing now for hours already anymore. Would be funny if the error itself would have been part of the write permissions. Anyway. Ill let you know on the next crash, A dump file got generated or not. – Zaibis Feb 20 '14 at 10:27
  • Well the server crashed yesterday again and still no core dump file :/ – Zaibis Feb 25 '14 at 06:57
0

I figured out how to solve the problem by my self.

I don't know why this is necessary, but I had to change the owner of the binary file from root, to the user which is spawn-fcgi running my app with. and now it generates a core file.

Zaibis
  • 69
  • 6