gdraheim / docker-systemctl-replacement

docker systemctl replacement - allows to deploy to systemd-controlled containers without starting an actual systemd daemon (e.g. centos7, ubuntu16)
European Union Public License 1.2
1.39k stars 399 forks source link

some improvement for systemctl3.py #173

Closed ladyrick closed 9 months ago

ladyrick commented 9 months ago
  1. Fix SyntaxWarning: invalid escape sequence '\w'

    企业微信截图_2097098b-93d6-4cbd-8170-08e43ae4041b
  2. Support multiple cmd path. Sometimes the "cat" command is not "/usr/bin/cat". So I change CAT_CMD to a list of candidates CAT_CMDS and search for the first existing path. Same change for LESS_CMD and TAIL_CMD.

    image
  3. In log_unit_from, instead of spawnvp a new process for cat/tail/less, I use execvp to replace current process. By doing this, systemctl needn't to handle the exit code and errors. For example, before this PR, when I use systemctl log -f service to see the log and then use ctrl+c to exit, I will get an ugly error like this. But when this PR is accepted, the tail command will exit directly and no error will show.

    企业微信截图_c8c2d440-3af7-4e26-b4a6-748bb7ce778e
gdraheim commented 9 months ago

Please add get_exist_path to systemctl3.pyi

ladyrick commented 9 months ago

Please add get_exist_path to systemctl3.pyi

Done.

gdraheim commented 9 months ago

Ahh, mypy asks for explicit return None in get_exist_path(paths):

ladyrick commented 9 months ago

Ahh, mypy asks for explicit return None in get_exist_path(paths):

Nice, All checks have passed this time.

gdraheim commented 9 months ago

I will do some more checks locally before pushing to master though. In any case, thanks a lot for the patch, that is really helpful for the project to continue.