You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there was an issue with getting the 3bot server run without sudo on macOS because of relying on some regex to find the process. this leads us in this PR and this PR to specify a check command to execute to find if the Nginx started or not yet.
but digging into the startupcmd implementation, after discussion with @abom I find that it should be able theoretically (with the original implementation) to get the PID of the started command, and then use that to decide if the process is running, without specifying regex or check cmd.
after testing a few commands, getting the PID attribute of the startupcmd instance worked as expected, except for Nginx case, and possibly other executables.
getting PID in startupcmd depends on the usages of the exec command and passing a name for the command with the -a option.
the code above will try to find the process using the sals.process.get_pids() which should return a list of processes ID(s) matching a given process name, in our Nginx case, startupcmd_nginx_main. but it will fail.
the name of the process that started is nginx, not as expected startupcmd_nginx_main.
to fix that we could search for the given name in the full command line instead of matching with only the process name part. this could be done easily, by setting the full_cmd_line parameter to True in jumpscale/tools/startupcmd/startupcmd.py.
then we could get rid of both the check_cmd and the process_strings_regex properties and is_running() will still behave as expected.
Steps to reproduce
1- create nginx startupcmd instance using startupcmd tool.
2- make sure both check_cmd and process_strings_regex properties are empty.
3- strat the cmd with start() method.
4- check the startupcmd instance pid or process properties, it won't return a result.
The text was updated successfully, but these errors were encountered:
Description
there was an issue with getting the 3bot server run without sudo on macOS because of relying on some regex to find the process. this leads us in this PR and this PR to specify a check command to execute to find if the Nginx started or not yet.
but digging into the startupcmd implementation, after discussion with @abom I find that it should be able theoretically (with the original implementation) to get the PID of the started command, and then use that to decide if the process is running, without specifying regex or check cmd.
after testing a few commands, getting the PID attribute of the startupcmd instance worked as expected, except for Nginx case, and possibly other executables.
getting PID in startupcmd depends on the usages of the
exec
command and passing a name for the command with the-a
option.https://github.com/threefoldtech/js-ng/blob/811a4358257556481d1a150d3499339e502eaa56/jumpscale/tools/startupcmd/startupcmd.py#L294
then to find the PID, it will try to find the process with the name set during the command execution.
https://github.com/threefoldtech/js-ng/blob/811a4358257556481d1a150d3499339e502eaa56/jumpscale/tools/startupcmd/startupcmd.py#L67-L73
the code above will try to find the process using the sals.process.get_pids() which should return a list of processes ID(s) matching a given process name, in our Nginx case,
startupcmd_nginx_main
. but it will fail.checking
ps
command output:the name of the process that started is
nginx
, not as expectedstartupcmd_nginx_main
.to fix that we could search for the given name in the full command line instead of matching with only the process name part. this could be done easily, by setting the
full_cmd_line
parameter toTrue
in jumpscale/tools/startupcmd/startupcmd.py.then we could get rid of both the
check_cmd
and theprocess_strings_regex
properties andis_running()
will still behave as expected.Steps to reproduce
1- create nginx startupcmd instance using startupcmd tool.
2- make sure both
check_cmd
andprocess_strings_regex
properties are empty.3- strat the cmd with start() method.
4- check the startupcmd instance
pid
orprocess
properties, it won't return a result.The text was updated successfully, but these errors were encountered: