dbus systemctl error : GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name com.example.Interface was not provided by any .service files - qml

I am new to systemctl.
I want to register a binary file using dbus with systemctl and use it.
When the binary file created by cmake is executed, it works normally.
However, if you run systemctl after registering the service file, it does not work properly.
There are server, clientA, and B services to register systemctl.
Here is the service file.
[Unit]
Description=Server Service...
After=network.target
[Service]
ExecStart=/opt/test/bin/dbusExample_Server
ExecStop=/opt/test/bin/dbusExample_Server
Restart=on-failure
RestartSec=60
[Install]
WantedBy=multi-user.target
[Unit]
Description=Client A Service...
After=network.target
[Service]
BusName=com.example.Interface
ExecStart=/opt/test/bin/helloString
ExecStop=/opt/test/bin/helloString
Restart=on-failure
RestartSec=60
Environment="DISPLAY=:0"
[Install]
WantedBy=multi-user.target
[Unit]
Description=Client B Service...
After=network.target
[Service]
ExecStart=/opt/test/bin/B/dbusExample_Client_B
ExecStop=/opt/test/bin/B/dbusExample_Client_B
Restart=on-failure
RestartSec=60
Environment="DISPLAY=:0"
[Install]
WantedBy=multi-user.target
I run.
sudo systemctl daemon-reload
sudo systemctl start server.service
sudo systemctl start clientA.service
sudo systemctl start clientB.service
In my program, when qml is executed on client A and a message is input, a message is sent from the server, and a message is also received from client B.
Enter a message and check it.
sudo systemctl status server.service
sudo systemctl status clientA.service
sudo systemctl status clientB.service
When I checked the status of clientA.service, I could see the following error.
GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name com.example.Interface was not provided by any .service files
The path to my .service file is as follows.
/lib/systemd/system
I checked that it should be in a different path through a search, and moved the following path
/.local/share/dbus-1/services
/etc/systemd/system
But I haven't been able to verify that it works.
What points do I need to fix for it to work properly? Any help would be greatly appreciated!

Related

Systemctl service not executed on boot

I created a short script to set an interface to down,
[Unit]
Description=Down
[Service]
Type=simple
ExecStart=/usr/bin/base -c 'ifconfig eth0 down'
I have done systemctl enable, and systemctl start works as expected to set the interface to down.
However, on rebooting it is not executed after logging in. Is there anything I missed?
The above is done on a RPi4 with the 64-bit version of Raspberian OS.
Could you perhaps be missing the [Install] property?
[Install]
WantedBy=multi-user.target

Why won't my systemd REDIS service start in RHEL 7.9?

So I'm not sure how to even figure out what's happening. Running redis-server version 6.2.5 on RHEL 7.9. I can start REDIS with the user I want to run it as from the command line. But when I try to start it as a systemd service with the REDIS.service file:
[Unit]
Description=REDIS Service
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
User=myuser
Group=myuser
WorkingDirectory=/app/redis
ExecStart=/bin/redis-server /app/redis/primary.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
It fails. The journalctl entry shows:
Aug 27 08:57:18 computerName redis-server[119338]: 119338:C 27 Aug 2021
08:57:18.981 # Fatal error, can't open config file
'/app/redis/primary.conf': Permission denied
The redis directory and all of it's files are owned by the user I'm telling to run the service. I even went to the extent of putting 777 on the directory and files. Thanks for any help you can give me!
Eric
This server was a mess. There was previous install of redis on the server, the rpm database was corrupt, there were old services that weren't running but were still there. I had to do a lot of cleanup and perform a clean install and it started working.

Failed to start redis.service: Unit redis-server.service is masked

I Installed Redis Server on ubuntu 16.04. but when I try to start the redis service using
$ sudo systemctl start redis
I receive message:
Failed to start redis.service: Unit redis-server.service is masked.
I don't have any idea about this error.
I found the solution. I think it will help for others
| systemctl unmask servicename
$ sudo systemctl unmask redis-server.service
if redis.service file is missed in directory path /etc/systemd/system/redis.service so we have to create file into this directory using command like:
sudo nano /etc/systemd/system/redis.service and write following things
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
Here
Unit is description and defining the network behavior,
Service is to specify the service's behavior and
Install define the systemd target that the service should attach to if enabled.
Then create redis user group and directories using
sudo adduser --system --group --no-create-home redis
sudo mkdir /var/lib/redis (Create directory)
sudo chown redis:redis /var/lib/redis (Change owner permission)
sudo chmod 770 /var/lib/redis
run the service sudo systemctl start redis
It will be work fine and check the status using
sudo systemctl status redis
1.sudo systemctl unmask redis-server.service
if redis.service file is missed in directory path
/etc/systemd/system/redis.service ,so we have to create file into this directory using command like:
sudo nano /etc/systemd/system/redis.service and write following things
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
Then create redis user group and directories using
sudo adduser --system --group --no-create-home redis
sudo mkdir /var/lib/redis (Create directory)
sudo chown redis:redis /var/lib/redis (Change owner permission)
sudo chmod 770 /var/lib/redis
run the service sudo systemctl start redis It will be work fine and check the status using
sudo systemctl status redis
For Ubuntu users run
sudo systemctl restart redis-server
you must run code
sudo systemctl daemon-reload

error apache2.service" and "journalctl -xe"

Last time I try add new domain on localhost and I leave it on few weeks so now I try run my apache this command /etc/init.d/apache2 start and I get error
[....] Starting apache2 (via systemctl): apache2.serviceJob for apache2.service failed. See "systemctl status apache2.service" and "journalctl -xe" for details.
failed!
If i tried to do reinstall apache2 but it is still not work.
I just did these two lines.It worked.
Two web servers cannot be active on the one port at the same time
this code for apache & nginx:
or
if error journalctl -xe used this code
sudo apt-get install psmisc
sudo lsof -t -i tcp:80 -s tcp:listen | sudo xargs kill
Virtual Host configuration might cause this error
I solved this same problem by configuring my virtual host .conf files properly.
I created a virtual host & then removed the exapmle.conf file form /etc/apache2/sites-avalable/ but I didn't deleted the examle.conf file from /etc/apache2/sites-enabled/ for this reason i was getting this error.
Then I removed the example.conf file from both the folders( ../sites-enabled & ../sites-available ) and solved this issue.
If you tried to setup any virtual host recently, then try this solution.
Best of Luck
Kill the running process on the port. Hope it will work!
sudo apt-get install psmisc
sudo fuser 80/tcp
sudo lsof -i tcp:80
sudo lsof -i tcp:80 -s tcp:listen
sudo lsof -t -i tcp:80 -s tcp:listen | sudo xargs kill
Go
sudo nano /etc/apache2/apache2.conf
remove this line:
Include /etc/phpmyadmin/apache.conf
Then
service apache2 start/restart
This problem may be a result of some configuration files in apache missing. One of the solutions would be to purge the apache2 file.
You can type:
sudo apt-get purge apache2
Then reinstall apache2 by typing:
sudo apt-get install apache2
As stated in the error message, we just have to execute :
systemctl status apache2.service
or
journalctl -xe
And you will have more detail about the error (line of the error, or command misspelled, or module not included in the configuration, ...) :
for example you can have following detail Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration ==> you then need to execute a2enmod ssl, and then execute service apache2 restart
Also I notice a difference between service apache2 reload and service apache2 restart commands. In case of persisting errors you should execute service apache2 restart, and then execute journalctl -xe.
You type
sudo netstat -pant
You check are you using port 80. If used, `
sudo service 'service_name' stop
and
sudo service apache2 start
The problem is because some configuration files are deleted.
You can use the following command to replace configuration files that have been deleted, without purging the package:
sudo apt-get -o DPkg::Options::="--force-confmiss" --reinstall install apache2
execute sudo service apache2 status and check the result. it might be trying to bind to a port that is already in use

Error with rabbit-mq server

I am trying to setup OpenStack on Ubuntu 12.04 using devstack. Now, the error I am getting is:
Setting up rabbitmq-server (2.7.1-0ubuntu4) ...
Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
invoke-rc.d: initscript rabbitmq-server, action "start" failed.
dpkg: error processing rabbitmq-server (--configure):
subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
rabbitmq-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
++ err_trap
++ local r=100
++ set +o xtrace
stack.sh failed
Any idea why am I getting this error?
I had this issue twice, when either hostname or ip address in the hosts file didn't match.
Therefore, check that you provide the correct ip address and hostname in the /etc/hosts file
Run sudo cat /etc/hostname to see your hostname
Output:
yoursite
Run sudo nano /etc/hosts
File contains:
127.0.0.1 yoursite
As you see from cat /etc/hostname, hostname is the same as in the /etc/hosts:
Run sudo rabbitmq-server start to start the rabbitmq-server
Try deleting the folder /var/lib/rabbitmq and re-running ./stack.sh
If that doesn't work either, run the following after stach.sh fails:
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq
chown -R rabbitmq:rabbitmq /var/log/rabbitmq
service rabbitmq-server restart
and check the status of rabbitmq using "rabbitmqctl status"
Similar thing happen to me. Rabbit depends on being able to resolve a hostname, run this:
echo "127.0.0.1 $(hostname -s)" | sudo tee -a /etc/hosts
This way works for me.
First go to
sudo vim /etc/hosts
and set
127.0.0.1 <hostname>
then open firewall
sudo rabbitmq-plugins enable rabbitmq_management
sudo service rabbitmq-server restart
For a clean environment, this will not happen. You must run devstack for several times, and one of them failed but you didn't get it cleaned.
run command pf -ef | grep rabbitmq, kill all rabbitmq processes. then it would be fine to run ./stack.sh
it is highly recommended to run ./unstack.sh && ./clean.sh before ./stack.sh
Just to be sure, take a look to your local network
ip add
If there's no lo network, then you should enable it:
ifconfig lo up
Then restart the server again and let's see if it works again now
systemctl start rabbitmq-server
I had the same problem though my /etc/hosts and DNS were OK. I suspect that SystemV init script was started too early when the network was not ready yet. I rewrote the startup script to systemd on CentOS 7.8 and it seems to work well now.
[Unit]
Description=RabbitMQ
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
RuntimeDirectory=rabbitmq
PrivateTmp=true
Restart=on-failure
RestartSec=10
WorkingDirectory=/opt/data/rabbitmq/
User=rabbitmq
Group=rabbitmq
ExecStart=/opt/app/rabbitmq/default/sbin/rabbitmq-server
ExecStop=/opt/app/rabbitmq/default/sbin/rabbitmqctl stop
ExecStop=/bin/sh -c "while ps -p $MAINPID >/dev/null 2>&1; do sleep 1; done"
StandardOutput=journal
StandardError=inherit
[Install]
WantedBy=multi-user.target