This directory contains sample systemd service files to start and stop the Helix Server and Broker services using systemd rather than SysV init scripts.
If you are using systemd (e.g. with CentOS 7.x), you do not need to add symlinks in <CODE>/etc/init.d</CODE>, and do not need to run the <CODE>chkconfig</CODE> commands as described in the SDP Guide.
These instructions apply only after the <CODE>mkdirs.sh</CODE> script has been run for a given instance, as discussed in the SDP Guide.
To use the sample *.service files:
For each instance, create your own p4d_N.service file, copying from p4d_1.service. Here N is the instance name, e.g. '2' or 'acme'. If your instance has a broker, proxy, or other component that is to run on the current machine, create additional files as needed. See the p4broker_1.service file as an example.
Modify your *.service files, changing the Description fields as desired, and setting the ExecStart and ExecStop fields to call appropriate script to start and stop the particular service. For example, p4d_1.service would look like this:
<PRE> [Unit] Description=Helix Server Instance 1 Documentation=http://www.perforce.com/perforce/doc.current/manuals/p4sag/index.html
[Service] Type=forking ExecStart=/p4/1/bin/p4d_1_init start ExecStop=/p4/1/bin/p4d_1_init stop User=perforce
[Install] WantedBy=multi-user.target </PRE>
As root, copy your modified *service files to the <CODE>/etc/systemd/system</CODE> directory.
As root, run commands like these samples, substituting the service name:
<PRE> systemctl enable p4d_1 systemctl enable p4broker_1 </PRE>
Enabling the services will cause them to start after a reboot.
Verify that you can run the service. As either the root or perforce user, exercise the start, stop, and status commannds, such as:
<PRE> systemctl status -l p4d_1 systemctl status -l p4broker_1 systemctl start p4d_1 systemctl start p4broker_1 systemctl status -l p4d_1 systemctl status -l p4broker_1 systemctl stop p4d_1 systemctl stop p4broker_1 systemctl status -l p4d_1 systemctl status -l p4broker_1 </PRE>
At this point your should be live in action.
These basic systemd service files are essentially just wrappers to SysV init scripts. The systemd system has additional features that may be considered later.
Sample systemd Configuration == Overview -- This directory contains sample systemd _service_ files to start and stop the Helix Server and Broker services using systemd rather than SysV init scripts. If you are using systemd (e.g. with CentOS 7.x), you do not need to add symlinks in <CODE>/etc/init.d</CODE>, and do not need to run the <CODE>chkconfig</CODE> commands as described in the **_SDP Guide_**. These instructions apply only after the <CODE>mkdirs.sh</CODE> script has been run for a given instance, as discussed in the **_SDP Guide_**. To use the sample \*.service files: 1. For each instance, create your own *p4d__N_.service* file, copying from *p4d_1.service*. Here _N_ is the instance name, e.g. '2' or 'acme'. If your instance has a broker, proxy, or other component that is to run on the current machine, create additional files as needed. See the *p4broker_1.service* file as an example. 2. Modify your \*.service files, changing the Description fields as desired, and setting the ExecStart and ExecStop fields to call appropriate script to start and stop the particular service. For example, *p4d_1.service* would look like this: <PRE> [Unit] Description=Helix Server Instance 1 Documentation=http://www.perforce.com/perforce/doc.current/manuals/p4sag/index.html [Service] Type=forking ExecStart=/p4/1/bin/p4d_1_init start ExecStop=/p4/1/bin/p4d_1_init stop User=perforce [Install] WantedBy=multi-user.target </PRE> 3. As **root**, copy your modified \*service files to the <CODE>/etc/systemd/system</CODE> directory. 4. As **root**, run commands like these samples, substituting the service name: <PRE> systemctl enable p4d_1 systemctl enable p4broker_1 </PRE> Enabling the services will cause them to start after a reboot. 5. Verify that you can run the service. As either the **root** or **perforce** user, exercise the start, stop, and status commannds, such as: <PRE> systemctl status -l p4d_1 systemctl status -l p4broker_1 systemctl start p4d_1 systemctl start p4broker_1 systemctl status -l p4d_1 systemctl status -l p4broker_1 systemctl stop p4d_1 systemctl stop p4broker_1 systemctl status -l p4d_1 systemctl status -l p4broker_1 </PRE> At this point your should be live in action. Just the Basics -- These basic _systemd_ service files are essentially just wrappers to SysV init scripts. The _systemd_ system has additional features that may be considered later.
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#8 | 27201 | C. Thomas Tyler |
Removed PIDFile= directory in systemd, as it actually introduces an issue. We randomly get an error like: p4d_1.service: Supervising process 16545 which is not our child. We'll most likely not notice when it exits. The PIDFile directive was added for informational purposes, and is not needed for processing. Even without it, the Main PID is accurate. |
||
#7 | 27148 | C. Thomas Tyler | Added templates for systemd unit files. | ||
#6 | 27109 | C. Thomas Tyler |
Refined logic so that if a shutdown is attempted and there is no server.pid file, the 'fallback/2nd pass/assured shutdown' logic to do a 'p4 admin stop' files only if a 'p4 info' command can reach the server. Otherwise, the stop command is silently ignored. Refined exit code handling and fixed log interaciton issues. Fixed issue with systemd status not indicating successful startup. The systemd unit files now specify the Type as simple rather than forking, and defer to systemd to handle the forking. When systemd is used, the -d/--daemonsafe flags are removed from service start commands for p4p/p4broker/p4d, and for p4dtg the & is removed so the process is not started in the background. For compatibility with non-systemd systems, the -d/--daemonsafe flags are still applied when systemd is not in use. With this change, systemd's concept of whether the service is running should now be reliable. If you try to start without using systemd on a system for which a systemd unit file exists, an error is displayed -- a big, hopefully useful and informative error message. #review |
||
#5 | 25320 | C. Thomas Tyler | Removed NetworkManager from README.md, already removed from sample service files. | ||
#4 | 24927 | Robert Cowham | Fix markdown syntax for code sections. | ||
#3 | 23206 | C. Thomas Tyler |
Minor doc tweak to accout for sample systemd *.service file enhancement to require network start. |
||
#2 | 16563 | C. Thomas Tyler |
Routine Merge Down to dev from main using: p4 merge -b perforce_software-sdp-dev p4 resolve -as |
||
#1 | 15797 | C. Thomas Tyler | Routine Merge Down to dev from main for SDP. | ||
//guest/perforce_software/sdp/main/Server/Unix/setup/systemd/README.md | |||||
#1 | 15793 | C. Thomas Tyler |
Added sample systemd init scripts for the SDP for RHEL/CentOS 7 and other Linux distros that use systemd. Also updated README.md for firewalld. |