pschlan / cron-job.org

cron-job.org Open Source project
GNU General Public License v2.0
1.47k stars 254 forks source link

Select all jobs at once from the dashboard #242

Open Sulivan1999 opened 4 months ago

Sulivan1999 commented 4 months ago

Hello!

Would it be possible to create an option to select all jobs at once, directly on the panel?

When we need to delete or deactivate multiple jobs, we need to select them one by one and then do the action. When there are many jobs this becomes a bit tiring, the option to select them all would be interesting.

pschlan commented 4 months ago

Good point. Let me see what I can do.

kleenkanteen commented 4 months ago

Saw the same use case myself except to delete cron jobs I made when testing.

@pschlan Is this already implemented? I see it is. If not, could I pick up this task?

pschlan commented 4 months ago

Of course, feel free to work on it. That would be awesome.

kleenkanteen commented 4 months ago

I tried running the repo in a github codespace (smallest one with 8gb ram). I made a devcontainer from the provided Dockerfile. It uses Ubuntu 20.04 LTS.

I followed the steps on https://github.com/pschlan/cron-job.org?tab=readme-ov-file#example-environment-using-docker-compose but on step 4 with docker compose up, I get this error, posting as a gist because it is so long: https://gist.github.com/kleenkanteen/819ca0e714875dc955513f801eb7f19c

Any idea why it isn't builiding?

pschlan commented 4 months ago

I have never seen this. It might be running out of memory, can you try to assign more RAM, even if just for building?

kleenkanteen commented 4 months ago

Doubling the ram fixed the issue. All services started now and showing logs in terminal. Although I get this log showing up: chronos-1 | Chronos runtime error: MySQL_DB::connect(): Unknown MySQL server host 'mysql-node' (2)

my .env ends like this:

NODE_MYSQL_ROOT_PASSWORD=chronos
NODE_MYSQL_USER=chronos
NODE_MYSQL_PASSWORD=chronos
NODE_MYSQL_DATABASE=chronos_node

I tried changing the last name from chronos_node to mysql_node? It didn't remove the error. Reverted back.

kleenkanteen commented 4 months ago

I'm unable to create an account after opening up the frontend. Status of 500 from http://127.0.0.1:8010/api/ when clicking create account.

pschlan commented 4 months ago

Doubling the ram fixed the issue. All services started now and showing logs in terminal. Although I get this log showing up: chronos-1 | Chronos runtime error: MySQL_DB::connect(): Unknown MySQL server host 'mysql-node' (2)

That's not unusual during startup phase. It should retry and eventually succeed.

I'm unable to create an account after opening up the frontend. Status of 500 from http://127.0.0.1:8010/api/ when clicking create account.

Did you set a valid SMTP_SERVER which accepts emails?

kleenkanteen commented 4 months ago

That's not unusual during startup phase. It should retry and eventually succeed.

Looking at the terminal it keeps on happening.

Did you set a valid SMTP_SERVER which accepts emails?

Nope. Easiest way to do it? I would expect it to be setup in the docker compose file already.

Does using this work also?: https://www.ionos.ca/digitalguide/e-mail/technical-matters/set-up-docker-mail-server/

Here is what I see upon running docker compose up: https://gist.github.com/kleenkanteen/927e6a66a5d51c5eaa94fa7c94d487c6

kleenkanteen commented 4 months ago

I added this to docker-compose.yml:

  mailserver:
    image: docker.io/mailserver/docker-mailserver:latest
    container_name: mailserver
    hostname: mail-server
    # example.com should be replaced with the own domain for the mail server:
    ports:
        - "25:25"
        - "587:587"
        - "465:465"
    volumes:
        - ./docker-data/dms/mail-data/:/var/mail/
        - ./docker-data/dms/mail-state/:/var/mail-state/
        - ./docker-data/dms/mail-logs/:/var/log/mail/
        - ./docker-data/dms/config/:/tmp/docker-mailserver/
        # Path should be adjusted accordingly:
        - ./docker-data/nginx-proxy/certs/:/etc/letsencrypt/
        - /etc/localtime:/etc/localtime:ro
    environment:
        - ENABLE_FAIL2BAN=1
        # If letsencrypt for SSL/TLS certificate is used (otherwise adapt)
        - SSL_TYPE=letsencrypt
        - PERMIT_DOCKER=network
        - ONE_DIR=1
        - ENABLE_POSTGREY=0
        - ENABLE_CLAMAV=0
        - ENABLE_SPAMASSASSIN=0
        - SPOOF_PROTECTION=0
    cap_add:
        - NET_ADMIN # For Fail2Ban to work
        - SYS_PTRACE

and in .env changed this line: SMTP_SERVER=http://${CJO_DOMAIN}:25

Still upon creating an account, I get a 500 server error.

kleenkanteen commented 4 months ago

@pschlan any idea about the MySQL and mailserver error?

kleenkanteen commented 3 months ago

I isolated the MySQL issue by starting it by itself. Details here: https://gist.github.com/kleenkanteen/aa6b066ebb2857e4c0a6bc55be5bdae5

kleenkanteen commented 3 months ago

Ok after asking for help on stackoverflow it turns out the default_authentication_plugin is deprecated, image is mysql 8.4, but according to the docs, "the plugin is deprecated as of MySQL 8.0.27 and subject to removal in a future MySQL version."

Aaaand it just got disabled by default last month: https://github.com/docker-library/mysql/issues/1048

Also, /workspaces/cron-job.org/database/struct_node.sql, line 42, can't have the text field have a default value. Had to remove that. Now mysql-node and mysql-master start perfectly fine.

I will move on to adding mailserver to docker compose.

kleenkanteen commented 3 months ago

@pschlan So I'm reading over this guide for setting up a mail server where I can see the email contents and log in: https://docker-mailserver.github.io/docker-mailserver/latest/examples/tutorials/basic-installation/

But there's so much to setup. What is the easiest way to do this email account confirmation flow?

kleenkanteen commented 3 months ago

I am following this email guide: https://www.youtube.com/watch?v=4SQiTXHYrnw

which seems the simplest but upon sending an email, nothing sends. This is my email .env's:

SMTP_SERVER=localhost:2500

# Email sender address and return path. '%s' in the return path will be
# replaced by a VERP token which can be used to automatically processed
# bounce emails and match them to a user account (e.g. to disable sending
# further emails to this user).
CJO_EMAIL_SENDER=info@example.com
# CJO_EMAIL_RETURN_PATH=bounce+%s@bounces.example.com
CJO_EMAIL_RETURN_PATH=bounce+%@bounces.example.com

anything wrong with these?

terminal logs show this upon sending:

api-1           | 172.20.0.9 -  06/Jun/2024:16:59:09 +0000 "POST /api/index.php" 409
www-1           | 172.20.0.1 - - [06/Jun/2024:16:59:09 +0000] "POST /api/ HTTP/1.1" 409 5 "http://localhost:8010/signup" "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36" "-"
api-1           | NOTICE: PHP message: PHP Fatal error:  Uncaught ValueError: Unknown format specifier "@" in /var/www/html/lib/Mail.php:39
api-1           | Stack trace:
api-1           | #0 /var/www/html/lib/Mail.php(39): sprintf('bounce+%@bounce...', 'signup-4-35ebce...')
api-1           | #1 /var/www/html/resources/User.php(513): Mail->setVerp('signup', '4', Array)
api-1           | #2 /var/www/html/resources/User.php(487): UserManager::sendActivationEmail('easyascake1@gma...', 'en', Object(AccountConfirmationToken), '4')
api-1           | #3 /var/www/html/apimethods/CreateAccount.php(68): UserManager::createAccount('easyascake1@gma...', 'Sabh', 'S', 'easyascake', 'en', 'America/Toronto')
www-1           | 172.20.0.1 - - [06/Jun/2024:16:59:15 +0000] "POST /api/ HTTP/1.1" 200 851 "http://localhost:8010/signup" "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36" "-"
api-1           | #4 /var/www/html/lib/APIDispatcher.php(140): CreateAccount->execute(Object(stdClass), false, 'en')
api-1           | #5 /var/www/html/index.php(72): APIDispatcher->dispatch()
api-1           | #6 {main}
api-1           |   thrown in /var/www/html/lib/Mail.php on line 39
api-1           | 172.20.0.9 -  06/Jun/2024:16:59:15 +0000 "POST /api/index.php" 200
mailslurper-1   | time="2024-06-06T16:59:18Z" level=info msg="Mail collection page 1 retrieved" who=ServiceController
mailslurper-1   | time="2024-06-06T16:59:19Z" level=info msg="Mail collection page 1 retrieved" who=ServiceController
mailslurper-1   | time="2024-06-06T16:59:20Z" level=info msg="Mail collection page 1 retrieved" who=ServiceController
mailslurper-1   | time="2024-06-06T16:59:21Z" level=info msg="Mail collection page 1 retrieved" who=ServiceController
mailslurper-1   | time="2024-06-06T16:59:26Z" level=info msg="Mail collection page 1 retrieved" who=ServiceController
mailslurper-1   | time="2024-06-06T16:59:27Z" level=info msg="Mail collection page 1 retrieved" who=ServiceController
chronos-1       | App::processJobs(): Done waiting for plannedTime = 1717693200.
kleenkanteen commented 3 months ago

help me bro I've suffered enough to get this running to this point 😩 (jk I am not suffering but it is hard)

kleenkanteen commented 3 months ago

Ok so I found a way to bypass the email verification login without needing a SMTP server. I was able to login to the site using this method. Here are the steps after creating an account and it says confirmation email sent:

  1. In docker-compose.yml, after line 19, add this:
      - "3306:3306"

    This will expose the docker container on post 3306 of your machine.

  2. Then with your database IDE of choice, login at localhost (127.0.0.1) on port 3306. default user and pass is chronos. db name is chronos_master. Then in the user table, for the row of your new account, you set the status column to 1 which means it's verified.
  3. Now login with your account details and you will enter the dashboard.
pschlan commented 3 months ago

Sorry for not being able to support here, lots of stuff going on the last weeks. I hope I can have a look at this (and your PR - thanks so much for this) soon. I'm glad you found a way to unblock yourself for now.

kleenkanteen commented 3 months ago

Np, I asked for help on stack overflow and the folks there found the issue.

When I make a cronjob locally though I remember it saying the notifications table or something was not found. A few different tables. A good number of tables were there already when I connected to both MySQL db's through datagrip. Forgot to mention that and the error. Not sure why all necessary tables were not created initially?

On Thu, Jun 27, 2024, 3:24 AM Patrick Schlangen @.***> wrote:

Sorry for not being able to support here, lots of stuff going on the last weeks. I hope I can have a look at this (and your PR - thanks so much for this) soon. I'm glad you found a way to unblock yourself for now.

— Reply to this email directly, view it on GitHub https://github.com/pschlan/cron-job.org/issues/242#issuecomment-2193979026, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQF3ZKQCXHJJBEDPXQLAY2DZJO42BAVCNFSM6AAAAABIF5VTG6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJTHE3TSMBSGY . You are receiving this because you commented.Message ID: <pschlan/cron-job .@.***>

kleenkanteen commented 3 months ago

here is the full error message when I try creating a cronjob:

image

All of it is running in gh codespaces. One weird thing is that in datagrip, I can test the connection to chronos_master and chronos_node. It succeeds for chronos_node but not chronos_master. For the latter, it just infinite loads, see the loading sign at the bottom of this pic:

image

But for chronos_node, connection works:

image

Gist of my docker compose file: https://gist.github.com/kleenkanteen/71038837b8ea3d26e9aa4d1f21e362d0

kleenkanteen commented 3 months ago

Regarding connecting to mysql-master, found the issue. On line 21 in docker-compose.yml, it should be - "4307:3306". Since mysql by default is exposed on port 3306.

struct_node.sql for some reason is not fully executed, so only the first 2 tables are created in the mysql-node db. I tried deleting the parts with "DEFAULT x" as that caused an error with the struct_master.sql, but same deal.

One workaround is that in datagrip, I connected to mysql-node and ran the create table statements for the remaining 7 tables. Then I was able to create a cron job successfully.

pschlan commented 3 months ago

It seems MySQL strict mode is not correctly disabled in your setup. That would explain why some tables have not been created properly. It puzzles me a bit since for me it works without issues with the docker compose setup in the repo. I will check again ASAP.