grocy/grocy-desktop

Nginx returns "502 Bad Gateway" after 36-48 hours

Moskus opened this issue ยท 9 comments

If I leave grocy-desktop running (as you would), with external access enabled (at least), I will always get a "502 Bad Gateway" error from nginx. I first figured it had something to do with my reverse proxy setup, but it also happens with that disabled.

A stupid fix is to schedule this .bat-file:

@echo off  
echo Terminating Grocy...  
taskkill /im grocy-desktop.exe  
timeout /t 5  
start /min "" C:\Users\YOUR_USER_NAME\AppData\Local\grocy-desktop\grocy-desktop.exe

... but I would rather that grocy-desktop didn't stop working. ๐Ÿ˜‰

502 Bad Gateway means that the upstream server is not responding, grocy-desktop itself also uses nginx as the frontend webserver and upstreams requests to PHP via FastCGI.

So most probably the PHP FastCGI process(es) died, however, please check the logs (Help/Debug/Show PHP runtime output) to see what happened.

Yes, I would, but the log windows are blank... :(

Then it's hard to say what goes wrong...

Although this should of course not happen, another sign that grocy-desktop is not the ideal server solution... ;D

Where are the log files located? I'm sure I can find the actual files somewhere.

Yes, this is not ideal, but running grocy natively on Windows turns out to be a surprisingly amount of work... I'm thinking about spinning up a VM for grocy alone, but that seems overkill. ;)

There are no log files, what's (normally) visible in the mentioned window is just stdout and stderr of the (php.exe) process, code ref:

this.Process.BeginOutputReadLine();
this.Process.BeginErrorReadLine();

private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
if (e.Data != null)
{
this.OutputLines.Add(e.Data);
}
}

public string GetConsoleOutput()
{
return string.Join(Environment.NewLine, this.OutputLines);
}

private void ToolStripMenuItem_ShowPhpRuntimeOutput_Click(object sender, EventArgs e)
{
new FrmShowText(this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (FastCGI Server 1)", this.PhpFastCgiServer1.GetConsoleOutput()).Show(this);
new FrmShowText(this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (FastCGI Server 2)", this.PhpFastCgiServer2.GetConsoleOutput()).Show(this);
new FrmShowText(this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (FastCGI Server 3)", this.PhpFastCgiServer3.GetConsoleOutput()).Show(this);
new FrmShowText(this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (FastCGI Server 4)", this.PhpFastCgiServer4.GetConsoleOutput()).Show(this);
new FrmShowText(this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (FastCGI Server 5)", this.PhpFastCgiServer5.GetConsoleOutput()).Show(this);
new FrmShowText(this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (FastCGI Server 6)", this.PhpFastCgiServer6.GetConsoleOutput()).Show(this);
new FrmShowText(this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (FastCGI Server 7)", this.PhpFastCgiServer7.GetConsoleOutput()).Show(this);
new FrmShowText(this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (FastCGI Server 8)", this.PhpFastCgiServer8.GetConsoleOutput()).Show(this);
if (this.UserSettings.EnableBarcodeBuddyIntegration)
{
new FrmShowText("Barcode Buddy " + this.ResourceManager.GetString("STRING_PHPOutput.Text") + " (Websocket Server)", this.BarcodeBuddyWebsocketServer.GetConsoleOutput()).Show(this);
}
}

I also use Windows for clients/workstations and some servers, but most (PHP) things just run more efficiently on Linux, but Windows also has a webserver (IIS) which can also host PHP and it's not really hard to set it up...

I had one idea for this:
Maybe the PHP FastCGI process get killed after x requests (don't know what the default value is), I now disabled this by setting the environment variable PHP_FCGI_MAX_REQUESTS to 0 - maybe that helps with this.

That's included in the v1.8.0 release, already ready here, the Microsoft Store release usually takes a couple of days due to verification.

This is great, I'll try that! :)

I'm calling it fixed. Grocy-desktop has been running without issues for a week. ๐Ÿ˜

Cool, thanks for the feedback. ๐Ÿ™‚