Link to home
Start Free TrialLog in
Avatar of Bob
BobFlag for United States of America

asked on

Linux RHEL 7 Service Creation

When attempting to create service (RHEL 7) I get the following errors
[root@HCV171ORSPTAA02 system]# systemctl status p4d.service
● p4d.service - Perforce Server
   Loaded: loaded (/usr/lib/systemd/system/p4d.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-03-07 10:41:44 EST; 11min ago
  Process: 27156 ExecStart=/usr/bin/p4d -r /p4/root -p host:1666 -d (code=exited, status=203/EXEC)
 Main PID: 21953 (code=exited, status=255)

Mar 07 10:41:44 HCV171ORSPTAA02 systemd[1]: Starting Perforce Server...
Mar 07 10:41:44 HCV171ORSPTAA02 systemd[1]: p4d.service: control process exited, code=exited status=203
Mar 07 10:41:44 HCV171ORSPTAA02 systemd[1]: Failed to start Perforce Server.
Mar 07 10:41:44 HCV171ORSPTAA02 systemd[1]: Unit p4d.service entered failed state.
Mar 07 10:41:44 HCV171ORSPTAA02 systemd[1]: p4d.service failed.
Warning: p4d.service changed on disk. Run 'systemctl daemon-reload' to reload units.

# Example Perforce systemd file (p4d.service):
#
# This service file will start Perforce at boot, and
# provide everything needed to use systemctl to control
# the Perforce server process.

[Unit]
# Note that descriptions are limited to 80 characters:
Description=Perforce Server

# Starts Perforce only after the network services are
# ready:
After=network.target

[Service]
# The type should always be set to "forking" to support
# multiple Perforce processes:
Type=forking

# Set the system user used to launch this process (usually
# 'perforce':
User=pollickr

# The command used to start Perforce:
ExecStart=/usr/bin/p4d -r /p4/root -p host:1666 -d

[Install]
# Describes the target for this service -- this will always
# be 'multi-user.target':
WantedBy=multi-user.target

Open in new window

Avatar of David Favor
David Favor
Flag of United States of America image

Try using Type=simple.

Also, make sure /usr/bin/p4d -r /p4/root -p host:1666 -d works one the command line.

Note: Type=forking can be confusing. If you can run your p4d command in foreground + the process actually detaches from the TTY + associates with init (pid == 1), then use forking, otherwise likely best to use simple.

https://www.freedesktop.org/software/systemd/man/systemd.service.html provides excruciating detail.

Reading systemd docs is a great cure for insomnia.
Avatar of noci
noci

hm systemd... A rather underwhelming piece of software...
 I have now system that hangs halfway starting up..... (black screen)...
one cannot start from another system chroot into the system, all systemd command will tell you your are in a chroot, and refuse to work...
one cannot get to a console using a boot command with init=/bin/bash... well there is a bash prompt, but no dbus , no systemd ...  so still no systemctl management

The problem started when a update somehow crippled the X driver for some rather exotic graphics device.

So IF all is working correctly it has hardly any advantage over more classic startup systems.
In the case of failure of / during systemd startup you are borked.
(recovery mode on a system where root is disabled has it's challenges...)
Why not just use service and add it via chkconfig?
ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
David, it was there through Centos6 and can be added/used for Centos7.  

I have several services that only run under the service command.
Tip: If you attempt to mix service managers... well... yes you can... and likely this will be a constant source of irritation + system instability forever.

If you dislike systemd enough to use another service manager, best to pick an OpenRC Distro like Alpine.

I have made the mistake of trying to run mixed service managers a couple of times. Ended up having to wipe the disk + do a fresh install.

Now I just weep silently in the night. Wishing I'd never heard of systemd. :-)

Generally mixing service managers works... till it doesn't... then it's apocalypse time.
Doesn't bother me and does not cause system instability.  At all.