Commit Graph

77 Commits

Author SHA1 Message Date
Girish Ramakrishnan 8f6637773b shell: add option for maxLines 2024-11-18 07:59:05 +05:30
Girish Ramakrishnan df5ba25010 shell: add explicit bash() function 2024-10-16 10:40:17 +02:00
Girish Ramakrishnan 6c3ca9c364 shell: rework code to use shell.spawn
spawn gives out streams and we have more control over the stdout/stderr
buffers. otherwise, we have to provide a max buffer capture size to exec
2024-10-15 12:13:46 +02:00
Girish Ramakrishnan 7b648cddfd shell: direct exports not needed anymore 2024-10-15 09:26:02 +02:00
Girish Ramakrishnan a9e1d7641d shell: make require take a tag 2024-10-14 21:08:32 +02:00
Girish Ramakrishnan ca8695a1d3 typo 2024-10-14 18:26:16 +02:00
Girish Ramakrishnan 6361737cf4 sudo: use debug() to have provide timestamped logs
the exception is when sudo calls backupupload.js which already has timestamped
output because it uses node

an alternative idea is to maybe not use this flag at all and always parse the output.
this is a bit complicated since we have to look for a timestamp in a stream.
2024-10-14 15:38:55 +02:00
Girish Ramakrishnan 69f48ed11a apps: do not log app logs to output 2024-08-07 15:51:04 +02:00
Girish Ramakrishnan 9399040cd3 Fix log recursion
shell.sudo logs output to stdout/stderr intentionally. It is not meant
for scripts that generate much output (basically scripts/* files).

core of the issue is that none of the log commands require to use sudo.
they can just use normal tail. only app logs requires sudo because of the
logPaths directive in the manifest.
2024-07-25 17:48:58 +02:00
Girish Ramakrishnan b6fbc46b58 Revert "Add option to not log shell subprocess stdout+stderr"
This reverts commit 51bb2d2bc2.
2024-07-25 11:53:56 +02:00
Johannes Zellner 51bb2d2bc2 Add option to not log shell subprocess stdout+stderr
When tailing the box log file this leads to logline recursion
2024-07-25 10:22:02 +02:00
Girish Ramakrishnan b26ff08a3c shell: copy over code and signal values from cp object 2024-07-22 21:24:27 +02:00
Girish Ramakrishnan 7aec713e6c shell: fix streaming of stdout/stderr with sudo 2024-07-08 10:09:00 +02:00
Girish Ramakrishnan 60c4dd3875 sudo: add explicit captureStdout flag 2024-07-08 09:58:25 +02:00
Girish Ramakrishnan 07527fe2b1 shell: when using shell use child_process.exec
arg splitting messes up arguments and debug output
2024-02-28 18:34:07 +01:00
Girish Ramakrishnan bcc78d81a6 shell: also print the args 2024-02-28 17:56:20 +01: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 d0dc104ede logs: make logPaths work
we have to tail via sudo script

Fixes #811
2024-02-23 17:46:22 +01:00
Girish Ramakrishnan 4ebff09f73 lint 2024-02-22 16:50:35 +01:00
Girish Ramakrishnan e6aef755e3 shell: merge spawn into sudo 2024-02-22 12:43:23 +01:00
Girish Ramakrishnan 60994f9ed1 shell: docker run needs shell
don't want to get into parsing quotes!
2024-02-22 10:59:39 +01:00
Girish Ramakrishnan a6f078330f shell: no need to promise scoping 2024-02-21 19:40:27 +01:00
Girish Ramakrishnan cfd5c0f82b shell: rewrite exec to use execFile
this also renames execFile to execArgs
2024-02-21 18:54:43 +01:00
Girish Ramakrishnan 14c9260ab0 shell: exec encoding is utf8 by default and no shell
explicitly mark calls that require the shell
2024-02-21 17:47:25 +01:00
Girish Ramakrishnan 23cac99fe9 shell: remove spawn 2024-02-21 13:35:56 +01:00
Girish Ramakrishnan 2237d2bbb7 shell: remove usage of .spawn 2024-02-21 13:27:04 +01:00
Girish Ramakrishnan c1bb4de6a3 reverseproxy: use async exec 2024-02-21 12:33:04 +01:00
Girish Ramakrishnan 9b94cf18d0 convert more execSync to async 2024-02-21 11:00:12 +01:00
Girish Ramakrishnan b51071155a Use the async shell exec 2024-02-20 22:57:36 +01:00
Girish Ramakrishnan 26eb739b46 shell: add options to exec 2024-02-20 21:11:09 +01: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 13a8926f60 sudo: suppress starttask.sh logs in test 2023-07-13 09:01:14 +05:30
Girish Ramakrishnan 7af44e1fdd typo 2023-03-29 22:29:26 +02:00
Girish Ramakrishnan 8ef730ad9c backuptask: make upload/download async 2022-04-28 21:37:08 -07:00
Girish Ramakrishnan 7f89dfd261 add once.js 2022-04-15 19:01:35 -05:00
Girish Ramakrishnan 7709e155e0 more async'ification 2021-09-07 11:21:06 -07:00
Girish Ramakrishnan b5d6588e3e updater: async'ify 2021-08-31 13:12:14 -07:00
Girish Ramakrishnan 03e22170da appstore and support: async'ify 2021-08-18 23:38:18 -07:00
Girish Ramakrishnan 0a3a7cb1a3 debug: replace newline in args 2021-06-18 14:33:50 -07:00
Girish Ramakrishnan 238073fe48 volume: get status 2021-05-13 16:08:55 -07:00
Girish Ramakrishnan 4c938b5e77 shell: expose promises variant 2021-05-12 17:30:29 -07:00
Girish Ramakrishnan 199eda82d1 Use Array.isArray instead 2021-05-02 11:26:47 -07:00
Girish Ramakrishnan 442110a437 lint 2021-05-01 11:21:09 -07:00
Johannes Zellner d315c53ff8 Only rebuild sftp is something has changed 2020-08-21 09:24:06 +02:00
Girish Ramakrishnan 2112c7d096 sudo: remove the nice support 2020-08-06 16:44:35 -07:00
Girish Ramakrishnan d2882433a5 run backup uploader with a nice of 15
the gzip takes a lot of cpu processing and hogs the CPU. With a nice
level, we give other things higher priority.

An alternate idea that was explored was to use cpulimit. This is to
send SIGSTOP and SIGCONT periodically but this will not make use of the
CPU if it's idle (unlike nice).

Another idea is to use cgroups, but it's not clear how to use it with
the dynamic setup we have.

part of #691
2020-07-31 18:23:36 -07:00
Girish Ramakrishnan c07e215148 Use BoxError in on error cases 2019-12-05 09:54:29 -08:00
Girish Ramakrishnan 30eccfb54b Use BoxError instead of Error in all places
This moves everything other than the addon code and some 'done' logic
2019-12-04 11:02:54 -08:00
Girish Ramakrishnan a2da9bea58 backup: use ipc for communicating with upload process 2018-11-26 15:21:48 -08:00