Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command is already running (pid == 1) #118

Open
XA21X opened this issue Jun 11, 2018 · 3 comments
Open

Command is already running (pid == 1) #118

XA21X opened this issue Jun 11, 2018 · 3 comments

Comments

@XA21X
Copy link

XA21X commented Jun 11, 2018

Since #93, I don't believe pid is ever reset as a fail-safe?

Logs indicated that pre-generate was always returning command is already running so I was getting suspicious. I finally checked the appconfig and noticed that pid == 1, which will never not be running.

I believe this could happen if the preview generator crashes or is interrupted while executing php occ directly (via docker run/exec). If this is the case, some time-based check might still be valuable in addition to the pid check - that is, periodically update a watchdog timestamp in the appconfig and treat the previous instance as dead if it hasn't been updated for a while?

@XA21X
Copy link
Author

XA21X commented Jun 11, 2018

Or it might be easier to just special-case PID1? :P

@joshtrichards
Copy link
Member

I believe this could happen if the preview generator crashes or is interrupted while executing php occ directly (via docker run/exec).

Agreed, this could happen under some circumstances:

$this->setPID();
// Set timestamp output
$formatter = new TimestampFormatter($this->config, $output->getFormatter());
$output->setFormatter($formatter);
$this->output = $output;
$this->sizes = SizeHelper::calculateSizes($this->config);
$this->startProcessing();
$this->clearPID();

Or it might be easier to just special-case PID1? :P

True, it is probably most likely to happen with 1. Tempting! :)

Maybe also with Docker environments with their own PID namespaces?

If this is the case, some time-based check might still be valuable in addition to the pid check - that is, periodically update a watchdog timestamp in the appconfig and treat the previous instance as dead if it hasn't been updated for a while?

Maybe. Or just check for the other matching running processes (that look like other copies of us) outright and error out as already running in that case.

Related: #328

@st3iny
Copy link
Member

st3iny commented Apr 22, 2024

That is weird. Running exec should not start the command with PID 1 inside the running container.

But yeah, having a command to reset the pid lock or a fail-safe is probably a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants