systemctl Myservice.service not found - service

When I keep my Myservice.service file in /etc/systemd/system/Myservice.service. I get not-found error.
systemctl status Myservice
● Myservice.service
Loaded: not-found (Reason: Unit Myservice.service not found.)
Active: failed (Result: exit-code) since Thu 2020-08-27 11:04:58 EDT; 22min ago
Main PID: 3539430 (code=exited, status=125)
But when I keep the same service file in /lib/systemd/system/Myservice.service. It works fine.
But why doesn't it work in the first scenario? why systemd not able to find file in first case. How can I debug this scenario with systemd.

I figured it out, In RHEL 8, My Myservice.service default selinux context is unconfined_u:object_r:admin_home_t:s0 under /etc/systemd/system/, I changed it to system_u:object_r:systemd_unit_file_t:s0. and That's it!

Related

Getting error "Failed to start Artifactory service" after Artifactory installation

Getting this error after installing Artifactory
artifactory.service - Artifactory service
Loaded: loaded (/usr/lib/systemd/system/artifactory.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: protocol) since Mon 2023-02-13 14:14:06 UTC; 43s ago
Process: 1469 ExecStart=/opt/jfrog/artifactory/app/bin/artifactoryManage.sh start (code=exited, status=0/SUCCESS)
Main PID: 26760 (code=exited, status=143)
Feb 13 14:14:06 mbiazelkdynatrace systemd[1]: Failed to start Artifactory service.
Feb 13 14:14:06 mbiazelkdynatrace systemd[1]: Unit artifactory.service entered failed state.
Feb 13 14:14:06 mbiazelkdynatrace systemd[1]: artifactory.service failed.
[root#mbiazelkdynatrace run]# systemctl status artifactory.service
Please help figure out the issue; I've trying this for the last two weeks.
Since you are trying to start for the first time, there may be an issue with ports where the ports required for Artifactory might already being used.
The above snippet does not reveal anything of the issue.
Can you try to perform the below steps.
Stop Artifactory from service.
Navigate to $JFROG_HOME/artifactory/app/bin (ideally /opt/jfrog/artifactory/app/bin if you have not changed the default location)
./artifactoryctl start
Navigate to $JFROG_HOME/artifactory/var/log location
tail the console.log that should reveal what is the issue.
or artifactory-service.log should reveal the issue.
If nothing is found, share the error snippet from artifactory-service.log

Mongod Process starts but Systemctl status shows failed

I have created a mongod configuration in /home/cluster1.conf with the same port I used previously for etc/mongod.conf.
I used to run etc/mongod.conf as a sudo user but expect to run cluster1.conf as user.
when I run cluster1.conf as user, the process starts. I accessed it from mongo shell and did operations. But when I'm trying to access it from another vm from the same VPC, it failed.
I checked for systemctl status mongod and it shows service is not running.
Why does systemctl status shows it not running when it really does? How can I resolve this to create a replica set??
"when I run cluster1.conf as user, the process starts." does not make much sense. cluster1.conf is a configuration file, it does not start anything.
When you run systemctl status mongod, then it typically shows
● mongod.service - MongoDB Database Server
Loaded: loaded (/etc/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2021-08-27 09:44:26 CEST; 2 weeks 3 days ago
Docs: https://docs.mongodb.org/manual
Main PID: 38710 (mongod)
Tasks: 28
Memory: 270.8M
CGroup: /system.slice/mongod.service
└─38710 /usr/bin/mongod -f /etc/mongod.conf
Check the service file /etc/systemd/system/mongod.service there you see entry like
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
Which means, config file /etc/mongod.conf is used (rather than /home/cluster1.conf)

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

I am installing ELK and I am facing some issues. How do I resolve it?

I am installing ELK on my Ubuntu 16.04 VM and I am not facing some issues after running the command even after having have done all the necessary changes in the elasticsearch.yml file. Please help me resolve this issue.
Below is the error after runnung the command, service elasticsearch status:
service elasticsearch status
* elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-11-06 07:36:45 GMT; 1h 37min ago
Docs: http://www.elastic.co
Main PID: 73248 (code=exited, status=1/FAILURE)
Check the configuration changes done to elasticsearch. Service is not able to start due to invalid configuration.

Converting chef upstart template to systemd

I have one upstart template in chef-Cookbook and want to convert it into Systemd so that it can be supported in 16.04.
I have already converted but faced the issue as my server is not starting properly.
Below is the upstart script -
#!upstart
description "Server nodejs"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on [!12345]
console log
setuid root
setgid www-data
chdir /srv/
exec /usr/local/bin/node /srv/my_service/src/cli/index.js >>/var/log/my_service/my_service_nodejs.log 2>&1
Conversion of same in Systemd is -
[Unit]
Description=Server nodejs
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/srv/
ExecStart=/usr/local/bin/node /srv/my_service/src/cli/index.js >>/var/log/my_service/my_service_nodejs.log 2>&1
[Install]
WantedBy=multi-user.target
Issues I am facing -
Node js Server is not Running
my_nodejs.service - Server nodejs
Loaded: loaded (/etc/systemd/system/my_nodejs.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2017-12-28 08:01:14 UTC; 6s ago
Main PID: 5842 (code=exited, status=64)
systemd[1]: my_nodejs.service: Main process exited, code=exited, status=64/n/a
systemd[1]: my_nodejs.service: Unit entered failed state.
systemd[1]: my_nodejs.service: Failed with result 'exit-code'.
Found the issue.
It is because of the >> which I added for appending log. >> is considered an Operator in Systemd