I try to run the process in the background as a deamon, but it only works when I use root as a user.
This is what I did.
Installed supervisor, as stated on their website
$ yum -y install python-setuptools $ easy_install supervisor
created configuration folders
$ mkdir -p /etc/supervisor/conf.d
filled with default settings
$ echo_supervisord_conf > /etc/supervisor/supervisord.conf
add new user
$ useradd gogopher
on CentOS 7, to start it automatically, I had to do it
$ vim /usr/lib/systemd/system/supervisord.service
added code below
[Unit] Description=supervisord - Supervisor process control system for UNIX Documentation=http://supervisord.org After=network.target [Service] Type=forking ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf ExecReload=/usr/bin/supervisorctl reload ExecStop=/usr/bin/supervisorctl shutdown User=gogopher [Install] WantedBy=multi-user.target
Now I can turn it on so that it starts on reboot. it all works great.
$ systemctl enable supervisord $ systemctl start supervisord $ systemctl status supervisord
Ok
editing a configuration file to include files from the conf.d folder
$ vim /etc/supervisor/supervisord.conf
append to end of file
[include] files = /etc/supervisor/conf.d/*.conf
adding a simple program
$ vim /etc/supervisor/conf.d/goapp.conf [program:main] command=/srv/www/websiteurl.com/bin/main autostart=true autorestart=true startretries=10 user=gogopher
$ systemctl restart supervisord
no error, but the process does not work
If I restart, nothing will happen
$ systemctl status supervisord
indicates that the supervisor is running, but not the daemon.
if i run
$ supervisorctl reload
I get an error
error: <class 'socket.error'>, [Errno 111] Connection refused: file: /usr/lib64/python2.7/socket.py line: 571
if i run
$ supervisorctl status main
I get an error
http:
I have already disabled selinux.
but the strange part is that if I changed both of them to root, it works.
An executable file can be executed by a group of users and others.
Therefore, I have no idea what is happening. I heard that I should not use root as the user who runs the web server for security reasons.