etsy / 411

An Alert Management Web Application
https://demo.fouroneone.io
MIT License
969 stars 112 forks source link

411 Setup documentation seems outdated for crontab section #27

Closed kasperbrandenburg closed 7 years ago

kasperbrandenburg commented 7 years ago

Hi,

In the initial setup guide, the cronjob configuration seems outdated. I've followed the guide today, and got the system up and running, but cronjob didn't work

# Add the following line into your crontab.
$ crontab -u USER -e
 /var/www/411/bin/cron.php > /dev/null 2>&1 && /var/www/411/bin/worker.php > /dev/null 2>&1

Running the CRON itself produces the following error

[+] Scheduler: 1475078702
except [NONE] Errno 2: "pcntl_exec(): Error has occurred: (errno 13) Permission denied" at [/var/www/411/phplib/Scheduler.php:44] 0:[pcntl_exec() called at [/var/www/411/phplib/Scheduler.php:44]] 1:[FOO\Scheduler->process() called at [/var/www/411/bin/cron.php:47]]
err [411_Scheduler] Scheduler error site:[1] ret:[256]

I had to change to this, which seems to make the cron functionality work

* * * * * php /var/www/411/bin/cron.php --backfill --date=/$(date +\%Y-\%m-\%d) --site=1
* * * * * php /var/www/411/bin/worker.php --site=1**

am i completely off, or is this correct?

kiwiz commented 7 years ago

@kasperbrandenburg Hey there. I think the problem is the files aren't executable. Can you try chmod +x on cron.php and worker.php and seeing if that gives better results?

kasperbrandenburg commented 7 years ago

Still seems to break after added +X

root@ubuntu-template:/var/www/411/bin# chmod +x cron.php
root@ubuntu-template:/var/www/411/bin# chmod +x worker.php
root@ubuntu-template:/var/www/411/bin# php cron.php

[+] Scheduler: 1475081804
except [NONE] Errno 2: "pcntl_exec(): Error has occurred: (errno 2) No such file or directory" at [/var/www/411/phplib/Scheduler.php:44] 0:[pcntl_exec() called at [/var/www/411/phplib/Scheduler.php:44]] 1:[FOO\Scheduler->process() called at [/var/www/411/bin/cron.php:47]]
err [411_Scheduler] Scheduler error site:[1] ret:[256]

root@ubuntu-template:/var/www/411/bin# ls -lh
total 36K
-rw-r--r-- 1 www-data www-data  597 Sep 28 12:44 backfill.php
-rw-r--r-- 1 www-data www-data  881 Sep 28 12:44 create_site.php
-rw-r--r-- 1 www-data www-data  879 Sep 28 12:44 create_user.php
-rwxr-xr-x 1 www-data www-data 1.1K Sep 28 12:44 cron.php
-rw-r--r-- 1 www-data www-data  698 Sep 28 12:44 db_cleanup.php
-rw-r--r-- 1 www-data www-data  769 Sep 28 12:44 es_sync.php
-rw-r--r-- 1 www-data www-data 1.3K Sep 28 12:44 migration.php
-rw-r--r-- 1 www-data www-data  281 Sep 28 12:44 shell.php
-rwxr-xr-x 1 www-data www-data  776 Sep 28 12:44 worker.php
root@ubuntu-template:/var/www/411/bin#
kasperbrandenburg commented 7 years ago

My own --date parameter did not work, cron.php will default if --date is not provided. I removed it

kiwiz commented 7 years ago

Hm, does the user the cron is running as have read access to that directory?

kasperbrandenburg commented 7 years ago

Running as root, and i just run chmod 777 recursively on /var/www/411/ Errormessages has changed


root@ubuntu-template:/var/www/411# php bin/cron.php
the time: 1475085910[+] Scheduler: 1475085910
except [NONE] Errno 2: "pcntl_exec(): Error has occurred: (errno 2) No such file or directory" at [/var/www/411/phplib/Scheduler.php:44] 0:[pcntl_exec() called at [/var/www/411/phplib/Scheduler.php:44]] 1:[FOO\Scheduler->process() called at [/var/www/411/bin/cron.php:48]]
err [411_Scheduler] Scheduler error site:[1] ret:[256]
kiwiz commented 7 years ago

Scheduler.php:39 defines a variable called $cmd. Can you check whether this contains the full path of the cron.php script?

kasperbrandenburg commented 7 years ago
           // This is the child. Launch the scheduler for this site.
            if($pid === 0) {
                $cmd = sprintf('%s/bin/cron.php', BASE_DIR);
                echo "----".$cmd."----";
                $args = ["--date=$date", "--site={$site['id']}"];
                if($backfill) {
                    $args[] = '--backfill';

This was the output. Looks good to me ----/var/www/411/bin/cron.php----

kiwiz commented 7 years ago

I'm out of ideas at this point... As a workaround, you could try invoking cron.php --site=1 instead of just cron.php.

kasperbrandenburg commented 7 years ago

Yep, that seems to work... lets leave it at that.