3

as ec2-user:

[ec2-user@stg etc]$ sudo supervisorctl status
sudo: supervisorctl: command not found

as root:

[ec2-user@stg etc]$ sudo su -
Last login: Tue Jun  6 03:02:55 UTC 2017 on pts/1
[root@stg ~]# supervisorctl status
kafka                            BACKOFF   Exited too quickly (process log may have details)
zookeeper                        RUNNING   pid 24697, uptime 0:25:11

I am not able to understand why this is happening. I checked sudoers file but did not find something meaningful. Please help.

1

2 Answers 2

5

This usually means that the command is not on the EC2 user's PATH.

If you do echo $PATH in both bash sessions you still see that root has /usr/sbin/ on their path.

To fix this, you can add to the ec2-user's path by adding the following to .bashrc: export PATH="$PATH:/usr/sbin/"

Alternatively, the full path to the executable, sudo /usr/sbin/supervisorctl should work.

1
  • root path [root@stg ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/root/bin ec2-user path [ec2-user@stg ~]$ echo $PATH /home/ec2-user/.pyenv/shims:/home/ec2-user/.pyenv/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
    – Avinash
    Jun 6, 2017 at 8:02
2

after going back and forward, it was simple supervisor uses python 2.6 and doesnt work with 2.7 on amazon linux ami, apparently (rhel fedora) u can verify this by

#python2.6 -c "import supervisor; print('success')"

success

#python2.7 -c "import supervisor; print('success')"

Traceback (most recent call last): File "", line 1, in ImportError: No module named supervisor

so u need to tell the system to use 2.6 instead of 2.7 - and u really have to make sure that this is safe to do - u dont want others app to start messing up. (am assuming u have both 2.6 and .27 installed already)

so steps to fix:

first run this command

# sudo update-alternatives --config python

a menu will appear select the right one. #

There are 2 programs which provide 'python'.

Selection    Command
-----------------------------------------------
*+ 1           /usr/bin/python2.7
   2           /usr/bin/python2.6

Enter to keep the current selection[+], or type selection number: 2
# 

choose the right one and ur set to go.

finally, try this one :

$ sudo /etc/init.d/supervisord start
Starting supervisord:                                      [  OK  ]

problem Solved!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .