Perforce is not providing standard script to run the perforce server p4d as service on Linux systems. Different people configured it in different way. Here is my way of running it as service on RHEL machines.
#!/bin/sh
# description: This is a daemon which starts perforce server on reboot
PATH=/sbin:/bin
test -f /home/perforce/server/p4d || exit 0
export P4ROOT=/home/perforce/server
export P4PORT=1818
RUN_AS_USER=perforce
case "$1" in
start)
su -m $RUN_AS_USER -c "/home/perforce/server/p4d -r $P4ROOT -J /home/perforce/logs/journal -L /home/perforce/logs/p4err -p tcp:$P4PORT &"
;;
stop)
/usr/local/bin/p4 admin stop
;;
*)
echo "Usage: /etc/init.d/p4proxy {start|stop}"
exit 1
esac
exit 0
Here note that we are not running p4d as root, instead using the account 'perforce'
- Create an account 'perforce' in your machine
- Download p4d and place it in designated directory as defined P4ROOT. Provide exec permission for it. And also change the owner to 'perforce' account.
- Create a start-up script 'p4d' at /etc/init.d
#!/bin/sh
# description: This is a daemon which starts perforce server on reboot
PATH=/sbin:/bin
test -f /home/perforce/server/p4d || exit 0
export P4ROOT=/home/perforce/server
export P4PORT=1818
RUN_AS_USER=perforce
case "$1" in
start)
su -m $RUN_AS_USER -c "/home/perforce/server/p4d -r $P4ROOT -J /home/perforce/logs/journal -L /home/perforce/logs/p4err -p tcp:$P4PORT &"
;;
stop)
/usr/local/bin/p4 admin stop
;;
*)
echo "Usage: /etc/init.d/p4proxy {start|stop}"
exit 1
esac
exit 0
Here note that we are not running p4d as root, instead using the account 'perforce'
- Add a new service for management through chkconfig
- Configure the run levels on which it needs to be on
It creates soft-links like
ls -ltr /etc/rc3.d/S29p4d
lrwxrwxrwx 1 root root 13 Sep 4 16:36 /etc/rc3.d/S29p4d -> ../init.d/p4d- Verify it by running commands
service p4d stop
No comments:
Post a Comment