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

Lockfile permissions not set #86

Open
ghost opened this issue Sep 20, 2017 · 5 comments
Open

Lockfile permissions not set #86

ghost opened this issue Sep 20, 2017 · 5 comments
Labels

Comments

@ghost
Copy link

ghost commented Sep 20, 2017

I've run into a permissions issue when running crons from multiple users due to lockfile ownership. When user_a runs jobby the lockfile is created and owned by user_a. When user_b later goes to run, it can't use the lockfile because it doesn't have write permissions.

IMO the mode should be set to 0666.

Is this intended functionality? If not, I'll gladly send a PR for a chmod in Helper :)

@hellogerard
Copy link
Member

I think the assumption is that there is only a single app/website running on a machine. So there is only a single user that needs to run jobby. I could see this as a problem in a shared host environment, or if a machine is hosting multiple PHP apps.

The solution would not to be to open permissions on the lock file. The lock file name would have to differ among users so multiple lock files could exist at the same time.

@christof-b
Copy link
Contributor

I run into this issue too.
A simple solution could be to add an option for the lock file directory.
Currently this makes jobby unusable at shared hosts.

@ridaamirini
Copy link

Any updates ?

@christof-b
Copy link
Contributor

christof-b commented Aug 14, 2018

Currently I use a workarround right before initializing jobby:
ini_set('sys_temp_dir', '/path/to/users/temp/dir');

@wujekbogdan
Copy link

wujekbogdan commented Jul 12, 2019

Any updates? I'm having the same issue on shared hosting. A solution would be to namespace the lock files with a unique namespace. The namespace could be configurable through one of the options passed to the Jobby constructor. It could default to '' in order to keep backwards compatibility.


EDIT
I'm looking at the source files and I found the following code:

    /**
     * @return string
     */
    protected function getLockFile()
    {
        $tmp = $this->tmpDir;
        $job = $this->helper->escape($this->job);

        if (!empty($this->config['environment'])) {
            $env = $this->helper->escape($this->config['environment']);

            return "$tmp/$env-$job.lck";
        } else {
            return "$tmp/$job.lck";
        }
    }

It seems that it is already implemented. The lock files are prefixed with the namespce defined by the environment setting.

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

No branches or pull requests

4 participants