supervisord not starting automatically on Ubuntu 20.04 - supervisord

I intalled latest superviosrd
pip install supervisord==4.2.1
and then I copied supervisord init script to /etc/init.d/supervisord
scp /path/to/init_script.sh /etc/init.d/supervisord
sudo update-rc.d supervisord defaults
and then I run:
sudo service supervisord start && sudo service supervisord status
got:
● supervisord.service - LSB: Starts supervisord - see http://supervisord.org
Loaded: loaded (/etc/init.d/supervisord; generated)
Active: active (exited) since Sat 2020-08-29 13:03:57 UTC; 19min ago
Docs: man:systemd-sysv-generator(8)
Tasks: 0 (limit: 1074)
Memory: 0B
CGroup: /system.slice/supervisord.service
Aug 29 13:03:57 vagrant systemd[1]: Starting LSB: Starts supervisord - see http://supervisord.org...
Aug 29 13:03:57 vagrant systemd[1]: Started LSB: Starts supervisord - see http://supervisord.org.
and then I check
supervisorctl
got
unix:///tmp/supervisor.sock no such file
supervisor>
However, if I manually run
supervisord
it will start:
redis STARTING
supervisor>
Any ideas on how I can make it run automatically on start? and why sudo service supervisord start does not start it?

To answer my own question, it is because the init script I was using has the following:
NAME=supervisord
DAEMON=/usr/bin/$NAME
SUPERVISORCTL=/usr/bin/supervisorctl
however, supervisord is installed in /usr/local/bin/, so I changed the path, and everything works now.

Related

Grafana-server Init Failed - Ubuntu 20.04

Using Grafana 8.3 in Ubuntu 20.04. When I went to the desktop environment to use Grafana, it wouldn’t connect. In the command line, when I type:
sudo netstat -lp
I noticed port 3000 wasn’t listed anymore.
starting the grafana server i get this below
a#a:~$ grafana-server
Grafana-server Init Failed: Could not find config defaults, make sure homepath command line parameter is set or working directory is homepath
when checking the status, I get this:
● grafana-server.service - Grafana instance
Loaded: loaded (/lib/systemd/system/grafana-server.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-01-05 16:06:11 MST; 11min ago
Docs: http://docs.grafana.org
Process: 4621 ExecStart=/usr/sbin/grafana-server --config=${CONF_FILE} --pidfile=${PID_FILE_DIR}/grafana-server.pid --packaging=deb cfg:default.paths.lo>
Main PID: 4621 (code=exited, status=1/FAILURE)
Jan 05 16:06:11 antonio- systemd[1]: grafana-server.service: Scheduled restart job, restart counter is at 5.
Jan 05 16:06:11 antonio- systemd[1]: Stopped Grafana instance.
Jan 05 16:06:11 antonio- systemd[1]: grafana-server.service: Start request repeated too quickly.
Jan 05 16:06:11 antonio- systemd[1]: grafana-server.service: Failed with result 'exit-code'.
Jan 05 16:06:11 antonio- systemd[1]: Failed to start Grafana instance.
thte only way I can get grafana to work in the desktop envionment is if I use and keep this open in the terminal:
$ sudo grafana-server -homepath /usr/share/grafana
Why has this happened and how can I use grafana without have to do this terminal step everytime?
thanks, I basically solved the problem by not solving the problem.
sudo apt-get purge grafana
sudo apt-get remove grafana
sudo apt-get remove --auto-remove grafana
then I deleted the config folder (contains the config file)
rm -R /etc/grafana/
then I reinstalled grafana
$ sudo apt-get install -y gnupg2 curl
$ curl https://packages.grafana.com/gpg.key | sudo apt-key add -
$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
$ sudo apt-get update
$ sudo apt-get -y install grafana
$ sudo systemctl start grafana-server
Now its running as before, with default port 3000 on startup

systemd service activation for Python script fails

I want to register a python script as a daemon service, executed at system startup and running continuously in the background. The script opens network sockets, a local log file and executes a number of threads. The script is well-formed and runs without any compilation or runtime issues.
I used below service file for registration:
[Unit]
Description=ModBus2KNX Gateway Daemon
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/bin/ModBusDaemon.py
[Install]
WantedBy=multi-user.target
Starting the service results in below error:
● ModBusDaemon.service - ModBus2KNX Gateway Daemon
Loaded: loaded (/lib/systemd/system/ModBusDaemon.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2021-01-04 21:46:29 CET; 6min ago
Process: 1390 ExecStart=/usr/bin/python3 /usr/bin/ModBusDaemon.py (code=exited, status=1/FAILURE)
Main PID: 1390 (code=exited, status=1/FAILURE)
Jan 04 21:46:29 raspberrypi systemd[1]: Started ModBus2KNX Gateway Daemon.
Jan 04 21:46:29 raspberrypi systemd[1]: ModBusDaemon.service: Main process exited, code=exited, status=1/FAILURE
Jan 04 21:46:29 raspberrypi systemd[1]: ModBusDaemon.service: Failed with result 'exit-code'.
Appreciate your support!
Related posts brought me to the resolution for my issue. Ubuntu systemd custom service failing with python script refers to the same issue. The proposed solution adding the WorkingDirectory to the Service section resolved the issue for me. Though, I could not find the adequate systemd documentation outlining on the implicit dependency.
As MBizm saim you must also add WorkingDirectory.
And After that you must also run these commands:
sudo systemctl daemon-reload
sudo systemctl enable your_service.service
sudo systemctl start your_service.service

Redis fails to start with error: redis-server.service: Failed at step NAMESPACE spawning /usr/bin/redis-server: Stale file handle

After upgrading Debian, it has an issue starting redis-server.service.
In the output of journalctl -xe I see the following:
redis-server.service: Failed at step NAMESPACE spawning /usr/bin/redis-server: Stale file handle.
I can't start the redis-server.service and in the output of the systemctl start redis-server I have:
Job for redis-server.service failed because the control process exited with error code.
See "systemctl status redis-server.service" and "journalctl -xe" for details.
In the output of systemctl status redis-server I have:
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2018-01-29 10:29:08 MSK; 58s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Process: 11701 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=226/NAMESPACE)
Process: 11720 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=226/NAMESPACE)
Main PID: 10193 (code=exited, status=0/SUCCESS)
Jan 29 10:29:08 xxx systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
Jan 29 10:29:08 xxx systemd[1]: redis-server.service: Scheduled restart job, restart counter is at 5.
Jan 29 10:29:08 xxx systemd[1]: Stopped Advanced key-value store.
My question how to fix this issue and start redis-server.service?
Found a workaround solution:
I've played around with the /lib/systemd/system/redis-server.service editing service file as root, commenting out different fields trying to find where the failure happens and restarting systemd (via systemctl daemon-reload, systemctl stop redis-server, systemctl start redis-server)
For me the issue was the following line in the redis-server.service file:
ReadOnlyDirectories=/
which I have commented out and that allowed redis-server to start succesfully.
So my current /lib/systemd/system/redis-server.service is:
[Unit]
Description=Advanced key-value store
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)
[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
ExecStop=/bin/kill -s TERM $MAINPID
PIDFile=/var/run/redis/redis-server.pid
TimeoutStopSec=0
Restart=always
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=2755
UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
#Modified 20180129 to avoid issue to start redis
#redis-server.service: Failed at step NAMESPACE spawning /usr/bin/redis-server: Stale file handle
#ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis
ReadWriteDirectories=-/var/log/redis
ReadWriteDirectories=-/var/run/redis
NoNewPrivileges=true
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
MemoryDenyWriteExecute=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
RestrictRealtime=true
RestrictNamespaces=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
# redis-server can write to its own config file when in cluster mode so we
# permit writing there by default. If you are not using this feature, it is
# recommended that you replace the following lines with "ProtectSystem=full".
ProtectSystem=true
ReadWriteDirectories=-/etc/redis
[Install]
WantedBy=multi-user.target
Alias=redis.service
I've just encountered this issue after running sudo apt -y dist-upgrade and got this slightly different error in /var/log/syslog
redis-server.service: Failed at step NAMESPACE spawning /usr/bin/redis-server: Invalid argument
The solution, Launchpad Bug 1638410, is:
sudo systemctl edit redis-server
[Service]
ProtectHome=no
Save and exit the editor and complete the upgrade:
sudo apt install -f
cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
$ apt policy redis-server
redis-server:
Installed: 5:5.0.0-3chl1~xenial1
Candidate: 5:5.0.0-3chl1~xenial1
Version table:
*** 5:5.0.0-3chl1~xenial1 500
500 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu xenial/main amd64 Packages
100 /var/lib/dpkg/status
2:3.0.6-1 500
500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
If you're using Ubuntu, in
/etc/redis/redis.conf
you should have :
supervised systemd

PG::ConnectionBad Postgres Cluster down

Digitalocean disabled my droplet's internet access. After fixing the error (rollback to older backup) they restored the internet access. But afterwards I constantly get an error when deploying, I can't seem to get my Postgres database up and running.
I'm getting an error each time I try to deploy my application.
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
So I used SSH to login to my server and check if my Postgres was actually running with:
pg_lsclusters
Results into:
Ver Cluster Port Status Owner Data directory Log file
9.5 main 5432 down postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
Postgres server status
So my Postgres server seems to be down. I tried putting it 'up' again with:
pg_ctlcluster 9.5 main start After doing so I got the error: Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 403.
And /usr/bin/pg_ctlcluster on line 403 says:
system 'systemctl', 'is-active', '-q', "postgresql\#$version-$cluster";
But I'm not to sure what the problem could be here and how I could fix this.
Update
I also tried updating the permissions on /bin to 755 as mentioned here. Sadly that did not fix my problem.
Update 2
I changed the /usr/bin to 755. Now when I try pg_ctlcluster 9.5 main start, I get this:
Job for postgresql#9.5-main.service failed because the control process exited with error code. See "systemctl status postgresql#9.5-main.service" and "journalctl -xe" for details.
And inside the systemctl status postgresql#9.5-main.service:
postgresql#9.5-main.service - PostgreSQL Cluster 9.5-main
Loaded: loaded (/lib/systemd/system/postgresql#.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-01-28 17:32:38 EST; 45s ago
Process: 22473 ExecStart=postgresql#%i --skip-systemctl-redirect %i start (code=exited, status=1/FAILURE)
Jan 28 17:32:08 *url* systemd[1]: Starting PostgreSQL Cluster 9.5-main...
Jan 28 17:32:38 *url* postgresql#9.5-main[22473]: The PostgreSQL server failed to start.
Jan 28 17:32:38 *url* systemd[1]: postgresql#9.5-main.service: Control process exited, code=exited status=1
Jan 28 17:32:38 *url* systemd[1]: Failed to start PostgreSQL Cluster 9.5-main.
Jan 28 17:32:38 *url* systemd[1]: postgresql#9.5-main.service: Unit entered failed state.
Jan 28 17:32:38 *url* systemd[1]: postgresql#9.5-main.service: Failed with result 'exit-code'.
Thanks!
You better not mix systemctl and pg_ctlcluster. Let systemctl makes the calls to pg_ctlcluster with the right user and permissions. You should start your postgresql instance with
sudo systemctl start postgresql#9.5-main.service
Also, check the errors in the startup log. You can post them too, to help you figure out what's going on.
Your systemctl status also outputs that the service is disable, so, when the server reboots, you will have to start the service manually. To enable it run:
sudo systemctl enable postgresql#9.5-main.service
I hope it helps
It is mainly because /etc/hosts file is somehow changed.I have removed extra space inside /etc/hosts file.Use cat /etc/hosts
Add these lines into the file
127.0.0.1 localhost
127.0.1.1 your-host-name
::1 ip6-localhost ip6-loopback
And I have given permission 644 to /etc/hosts file.It is working for me even after the reboot of the system.

Kestrel failed to start UBUNTU 16.04

I have the folowing config:
[Unit]
Description=Example .NET Web API Application running on CentOS 7
[Service]
WorkingDirectory=/var/www/FEEDER
ExecStart=/usr/bin/dotnet /var/www/FEEDER/FeedService.MVC.dll
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Development
[Install]
WantedBy=multi-user.target
when I start the prgram I dont get any error.
the status throw this:
sudo ystemctl status kestrel-hellomvc.service
● kestrel-hellomvc.service - Example .NET Web API Application running on CentOS 7
Loaded: loaded (/etc/systemd/system/kestrel-hellomvc.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since ג' 2017-10-31 09:26:20 IST; 54min ago
Main PID: 20077 (code=exited, status=131/n/a)
אוק 31 09:26:20 avi-VirtualBox systemd[1]: Stopped Example .NET Web API Application running on CentOS 7.
אוק 31 09:26:20 avi-VirtualBox systemd[1]: Started Example .NET Web API Application running on CentOS 7.
אוק 31 09:26:20 avi-VirtualBox systemd[1]: kestrel-hellomvc.service: Main process exited, code=exited, status=131/n/a
אוק 31 09:26:20 avi-VirtualBox systemd[1]: kestrel-hellomvc.service: Unit entered failed state.
אוק 31 09:26:20 avi-VirtualBox systemd[1]: kestrel-hellomvc.service: Failed with result 'exit-code'.
Warning: kestrel-hellomvc.service changed on disk. Run 'systemctl daemon-reload' to reload units.
the owner of the folder is www-data and the permissions are 0755
What might be the problem?
Thanks
you should deploy your app myapp with:
sudo cp -a /home/user/myapp/bin/Debug/netcoreapp2.0/publish/* /var/aspnetcore/myapp
eg.
Copy all files from build folder to deployment location (*.json etc)