Skip to content

stderr being printed out for Rex::Service instead of captured for $running_upstart #1612

@VVelox

Description

@VVelox

Describe the bug

sh: initctl: not found gets printed out any time Rex::Service->get is called.

Expected behavior

Redirects stderr to stdout to avoid

How to reproduce it

perl -e 'use Rex::Commands::Service; service snmpd=>"start";'
sh: initctl: not found
sh: initctl: not found
[2024-01-22 22:37:29] INFO - Service snmpd started.

Code example

use Rex::Commands::Service;
service snmpd=>"start";

Additional context

So looks like Rex::Commands::Service->service calls Rex::Service->get to get the object to use for it. When this happen a bit of code is ran to test for OS and if initctl and systemctl are usable.

I am lost as to why the systemctl check does not also do it.

Likely the best option here is to add which initctl > /dev/null && before it and likely do the same with systemctl as well.

[root@nibbles0]1|/src/ports/head>which initctl > /dev/null && echo test
[root@nibbles0]1|/src/ports/head>which ls > /dev/null && echo test     
test
[root@nibbles0]0|/src/ports/head>

Double check to make sure this issue is not caused by how it is being packaged and when reinstalled via cpanm --reinstall Rex the same thing happens.

Rex version

1.14.3

Perl version

v5.36.3

Operating system running rex

FreeBSD nibbles0.vulpes.vvelox.net 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64

Operating system managed by rex

FreeBSD and Linux

How rex was installed?

package manager

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bugs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions