Commit Graph

103 Commits

Author SHA1 Message Date
Johannes Zellner c0065765d4 Fix update UI to show progress and allow to cancel update task 2025-06-30 19:31:03 +02:00
Girish Ramakrishnan a02e3d2ebd better log 2025-06-20 22:16:05 +02:00
Girish Ramakrishnan 2db99e7807 refactor: rename updater functions to have box in them 2025-06-20 19:04:55 +02:00
Girish Ramakrishnan fb39aa32bb tasks: fix update failed notification
https://forum.cloudron.io/topic/13408/update-to-cloudron-8.3-error

We get a Task xx crashed with code null in the notification.

The crux of the issue is that we use KillMode=control-group. This ends
up sending SIGTERM signal to box code and all the sudo in parallel. The box
code then sees the sudo die and records the task as failed.

To fix, we switch to KillMode=mixed. This gives box code a chance to handle SIGTERM
first. It cleans out its task list and kills all the sudo.
2025-06-17 23:47:04 +02:00
Girish Ramakrishnan ca25c6075b tasks: fix grammar and log the completion of sudo 2025-06-17 22:33:30 +02:00
Girish Ramakrishnan d9c104613c tasks: rework the startTask API
it is now async. change was required to reset the pending flag
2025-06-17 19:32:46 +02:00
Girish Ramakrishnan 4770b32287 tasks: add pending field
this indicates if a task is scheduled. previously, we relied
on task.progress being 1
2025-06-17 17:00:21 +02:00
Girish Ramakrishnan dd5e4adc73 replace underscore with our own
we only need like 5 simple functions
2025-02-13 14:14:34 +01:00
Girish Ramakrishnan d456f91921 tasks: fix active status 2024-12-12 19:09:55 +01:00
Girish Ramakrishnan a9e1d7641d shell: make require take a tag 2024-10-14 21:08:32 +02:00
Girish Ramakrishnan d5ea99603f backups: give is a low oomScoreAdjust to not get killed 2024-07-19 13:05:09 +02:00
Girish Ramakrishnan 3dcd0975f7 test: fix various routes tests
* system/disks routes is gone
* provision routes now return 405 instead of 409 when re-setup/re-activated
2024-06-03 19:27:23 +02:00
Girish Ramakrishnan 13e62bc738 logs: use stream.destroy() instead of custom hooks 2024-02-24 17:35:37 +01:00
Girish Ramakrishnan 0e83658aa3 make sudo commands terminate properly
sudo forks and execs the program. sudo also hangs around as the parent of the program waiting on the program and also forwarding signals.
sudo does not forward signals when the originator comes from the same process group. recently, there has been a change where it will
forward signals as long as sudo or the command is not the group leader (https://www.sudo.ws/repos/sudo/rev/d1bf60eac57f)
for us, this means that calling kill from this node process doesn't work since it's in the same group (and ubuntu 22 doesn't have the above fix).
the workaround is to invoke a kill from a different process group and this is done by starting detached
another idea is: use "ps --pid cp.pid -o pid=" to get the pid of the command and then send it signal directly

see also: https://dxuuu.xyz/sudo.html
2024-02-24 16:19:07 +01:00
Girish Ramakrishnan 1ad94708b4 apps have to reconfigured in main thread
they cannot be done in the task process
2023-08-21 21:35:09 +05:30
Girish Ramakrishnan 4acbb7136a proper task name for dashboard change 2023-08-14 10:45:12 +05:30
Johannes Zellner 56e1f53890 Fix oidc tests after removing logoutRedirectUri 2023-07-28 16:47:10 +02:00
Girish Ramakrishnan 7926ff2811 test: only suppress starttask.sh output and not sudo
the remote support logic uses sudo output in tests
2023-07-13 09:13:28 +05:30
Girish Ramakrishnan 23f0eba1bd dyndns: run as a task
this lets us display logs
2023-07-08 21:21:06 +05:30
Girish Ramakrishnan e6ba2a6e7a replace usage of _.extend with Object.assign 2023-05-25 11:45:14 +02:00
Girish Ramakrishnan 94eb7849fe tasks: return 404 if task not found
part of #826
2023-05-15 10:16:00 +02:00
Girish Ramakrishnan c4f4f3e914 logs: use %o to format error
otherwise, they are printed as multi-line and this messes up tail+date formatting
2023-04-16 10:49:59 +02:00
Girish Ramakrishnan 603f92251e refactor tail invokation into logtail.sh 2023-03-27 11:39:34 +02:00
Girish Ramakrishnan 3b8221190d Better error mesasge 2022-11-20 18:16:16 +01:00
Girish Ramakrishnan ca44f47af3 replace split with our own LogStream
split module is archived
2022-11-06 13:44:47 +01:00
Girish Ramakrishnan 8bc3b832e7 detect oom in tasks correctly 2022-11-02 22:39:25 +01:00
Girish Ramakrishnan edb6ed91fe add disk usage task 2022-10-12 10:26:21 +02:00
Johannes Zellner ace96bd228 Fix stringification for debug of taskError object if set 2022-08-08 13:12:53 +02:00
Girish Ramakrishnan 05d7a7f496 constness 2022-04-14 17:50:41 -05:00
Girish Ramakrishnan 26bfa32c7b Fix display of task error 2022-02-01 21:47:49 -08:00
Girish Ramakrishnan 8644a63919 better debug 2021-09-23 17:38:55 -07:00
Girish Ramakrishnan c5794b5ecd get rid of all the NOOP_CALLBACKs 2021-09-17 09:40:26 -07:00
Girish Ramakrishnan a1c61facdc merge userdb.js into users.js 2021-07-16 22:33:22 -07:00
Girish Ramakrishnan e59d0e878d merge taskdb into tasks.js 2021-07-14 10:37:12 -07:00
Girish Ramakrishnan ef04253288 print the task options in the logs 2021-06-16 14:21:19 -07:00
Girish Ramakrishnan a5e34cf775 delete certs that have long expired (6 months)
fixes #783
2021-05-18 13:37:35 -07:00
Girish Ramakrishnan 2946657889 stopAllTasks: the box dir might disappear
during update, we stop the box code which ends up trying to stop all tasks.
this gives warning like below:

box:shell stopTask (stdout): shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
box:shell stopTask (stdout): job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
box:shell stopTask (stdout): box-task-8.service loaded active running /home/yellowtent/box/src/scripts/../taskworker.js 8 /home/yellowtent/platformdata/logs/tasks/8.log
box:shell stopTask (stdout): job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
box:shell stopTask (stdout): job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
box:shell stopTask (stdout): job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
2021-03-02 22:26:43 -08:00
Girish Ramakrishnan 70fbcf8ce4 add route to sync dns records
merge the mail dns route with this one as well

fixes #737
2021-02-24 22:37:59 -08:00
Girish Ramakrishnan bcd04715c0 updater: set the backup memory limit 2021-02-01 14:07:23 -08:00
Girish Ramakrishnan 88f24afae6 assume code 1 task 9 is oom
Fixes #750
2020-12-21 18:07:21 -08:00
Johannes Zellner aae79db27a Mention that we use task types also in the dashboard 2020-09-02 17:06:25 +02:00
Johannes Zellner 6a781c62ec Improve task progress values
0: not yet handled
1: queued
2: started
100: finished
2020-08-19 16:58:53 +02:00
Girish Ramakrishnan 3507269321 Allow mail server name to be configurable
Fixes #721
2020-08-17 21:49:59 -07:00
Girish Ramakrishnan c4101a62ed rename function to setupDnsAndCert
this way, we can reuse this logic for the mail domain as well
2020-08-17 16:18:48 -07:00
Girish Ramakrishnan d1e14ed691 rename function to setupDashboarDnsAndCert 2020-08-17 15:42:15 -07:00
Girish Ramakrishnan 7039108438 pass memory limit as argument to starttask.sh 2020-08-10 21:53:07 -07:00
Girish Ramakrishnan b1b6f70118 Kill all tasks on shutdown and startup
BindsTo will kill all the tasks when systemctl stop box is executed.
But when restarted, it keeps the tasks running. Because of this behavior,
we kill the tasks on startup and stop of the box code.
2020-08-06 23:47:40 -07:00
Girish Ramakrishnan 2112c7d096 sudo: remove the nice support 2020-08-06 16:44:35 -07:00
Girish Ramakrishnan ac63d00c93 run tasks as separate cgroup via systemd
this allows us to adjust the nice value and memory settings per task

part of #691
2020-08-06 16:43:14 -07:00
Girish Ramakrishnan e04871f79f pass log file as argument to task worker
initially, i thought i can hardcode the log file into taskworker.js
depending on the task type but for apptask, it's not easy to get the
appId from the taskId unless we introspect task arguments as well.
it's easier for now to pass it as an argument.
2020-08-05 00:46:34 -07:00