snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
21
misc/rpm/README.md
Normal file
21
misc/rpm/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
RPM for Centrifugo
|
||||
|
||||
```
|
||||
yum -y install rpmdevtools
|
||||
```
|
||||
|
||||
Go to directory containing all files listed here.
|
||||
|
||||
Download release to current folder:
|
||||
|
||||
```
|
||||
wget https://github.com/centrifugal/centrifugo/releases/download/v0.0.1/centrifugo-0.0.1-linux-amd64.zip -O centrifugo-0.0.1-linux-amd64.zip
|
||||
```
|
||||
|
||||
Build rpm:
|
||||
|
||||
```
|
||||
./build.sh 0.0.1
|
||||
```
|
||||
|
||||
As argument to `build.sh` you should specify Centrifugo version of release binary downloaded above.
|
||||
20
misc/rpm/build.sh
Executable file
20
misc/rpm/build.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
if [ "$1" = "" ]
|
||||
then
|
||||
echo "Usage: $0 <version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f centrifugo-$1-linux-amd64.zip ]; then
|
||||
echo "No Centrifugo release found in current directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp centrifugo-$1-linux-amd64.zip ~/rpmbuild/SOURCES/centrifugo-$1-linux-amd64.zip
|
||||
cp centrifugo.spec ~/rpmbuild/SPECS/centrifugo.spec
|
||||
cp centrifugo.initd ~/rpmbuild/SOURCES/centrifugo.initd
|
||||
cp centrifugo.nofiles.conf ~/rpmbuild/SOURCES/centrifugo.nofiles.conf
|
||||
cp centrifugo.logrotate ~/rpmbuild/SOURCES/centrifugo.logrotate
|
||||
cp centrifugo.config.json ~/rpmbuild/SOURCES/centrifugo.config.json
|
||||
|
||||
rpmbuild -bb ~/rpmbuild/SPECS/centrifugo.spec --define "version $1" --define "release `date +%s`"
|
||||
1
misc/rpm/centrifugo.config.json
Normal file
1
misc/rpm/centrifugo.config.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
148
misc/rpm/centrifugo.initd
Normal file
148
misc/rpm/centrifugo.initd
Normal file
@@ -0,0 +1,148 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# /etc/init.d/centrifugo
|
||||
#
|
||||
# Startup script for centrifugo
|
||||
#
|
||||
# chkconfig: 2345 20 80
|
||||
# description: Starts and stops centrifugo
|
||||
|
||||
# Source function library.
|
||||
if [ -f /etc/init.d/functions ] ; then
|
||||
. /etc/init.d/functions
|
||||
elif [ -f /etc/rc.d/init.d/functions ] ; then
|
||||
. /etc/rc.d/init.d/functions
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Daemon options
|
||||
CENTRIFUGO_OPTS=
|
||||
|
||||
# Process name
|
||||
NAME=centrifugo
|
||||
|
||||
# User and group
|
||||
USER=centrifugo
|
||||
GROUP=centrifugo
|
||||
|
||||
# Daemon name, where is the actual executable
|
||||
# If the daemon is not there, then exit.
|
||||
DAEMON=/usr/sbin/centrifugo
|
||||
|
||||
# Configuration file
|
||||
CONFIG=/etc/centrifugo/config.json
|
||||
|
||||
# Logging
|
||||
if [ -z "$STDOUT" ]; then
|
||||
STDOUT=/var/log/centrifugo/centrifugo.log
|
||||
fi
|
||||
|
||||
if [ ! -f "$STDOUT" ]; then
|
||||
mkdir -p $(dirname $STDOUT)
|
||||
fi
|
||||
|
||||
if [ -z "$STDERR" ]; then
|
||||
STDERR=/var/log/centrifugo/centrifugo.log
|
||||
fi
|
||||
|
||||
if [ ! -f "$STDERR" ]; then
|
||||
mkdir -p $(dirname $STDERR)
|
||||
fi
|
||||
|
||||
[ -e /etc/sysconfig/centrifugo ] && . /etc/sysconfig/centrifugo
|
||||
|
||||
lockfile="/var/lock/subsys/centrifugo"
|
||||
|
||||
if ! [ -x $DAEMON ]; then
|
||||
echo "$DAEMON binary not found."
|
||||
exit 5
|
||||
fi
|
||||
|
||||
start() {
|
||||
if ! [ -f $CONFIG ]; then
|
||||
echo "configuration file not found $CONFIG"
|
||||
exit 6
|
||||
fi
|
||||
configtest || return $?
|
||||
echo -n $"Starting $NAME: "
|
||||
daemon --user centrifugo --check=$DAEMON "nohup $DAEMON --config=$CONFIG $CENTRIFUGO_OPTS >>$STDOUT 2>&1 &"
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $NAME: "
|
||||
killproc $NAME -TERM
|
||||
retval=$?
|
||||
if [ $retval -eq 0 ]; then
|
||||
if [ "$CONSOLETYPE" != "serial" ]; then
|
||||
echo -en "\\033[16G"
|
||||
fi
|
||||
while rh_status_q
|
||||
do
|
||||
sleep 1
|
||||
echo -n $"."
|
||||
done
|
||||
rm -f $lockfile
|
||||
fi
|
||||
echo
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
configtest || return $?
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
configtest || return $?
|
||||
echo -n $"Reloading $NAME: "
|
||||
killproc $DAEMON -HUP
|
||||
sleep 1
|
||||
RETVAL=$?
|
||||
echo
|
||||
}
|
||||
|
||||
configtest() {
|
||||
$DAEMON checkconfig -c $CONFIG
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
status $NAME
|
||||
}
|
||||
|
||||
rh_status_q() {
|
||||
rh_status >/dev/null 2>&1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
restart|configtest)
|
||||
$1
|
||||
;;
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
status|status_q)
|
||||
rh_$1
|
||||
;;
|
||||
condrestart)
|
||||
rh_status_q && restart || exit 0
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|reload|status|restart|configtest|condrestart}"
|
||||
exit 2
|
||||
esac
|
||||
7
misc/rpm/centrifugo.logrotate
Normal file
7
misc/rpm/centrifugo.logrotate
Normal file
@@ -0,0 +1,7 @@
|
||||
/var/log/centrifugo/*log {
|
||||
copytruncate
|
||||
daily
|
||||
rotate 7
|
||||
compress
|
||||
missingok
|
||||
}
|
||||
1
misc/rpm/centrifugo.nofiles.conf
Normal file
1
misc/rpm/centrifugo.nofiles.conf
Normal file
@@ -0,0 +1 @@
|
||||
centrifugo - nofile 65536
|
||||
92
misc/rpm/centrifugo.spec
Normal file
92
misc/rpm/centrifugo.spec
Normal file
@@ -0,0 +1,92 @@
|
||||
%define debug_package %{nil}
|
||||
%define application_user %{name}
|
||||
%define application_group %{name}
|
||||
%define application_data %{_localstatedir}/lib/%{name}
|
||||
%define __prefix /opt
|
||||
|
||||
Name: centrifugo
|
||||
Version: %{version}
|
||||
Release: %{release}
|
||||
Summary: Real-time messaging server
|
||||
License: MIT
|
||||
URL: https://github.com/centrifugal/centrifugo
|
||||
Group: Apps/sys
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
|
||||
Packager: Alexandr Emelin <frvzmb@gmail.com>
|
||||
Requires(pre): shadow-utils
|
||||
Requires(post): /sbin/chkconfig
|
||||
Requires(preun): /sbin/chkconfig, /sbin/service
|
||||
Requires(postun): /sbin/service
|
||||
|
||||
%description
|
||||
Real-time messaging server written in Go
|
||||
|
||||
%prep
|
||||
cd ~/rpmbuild/BUILD
|
||||
rm -rf %{name}-%{version}-linux-amd64
|
||||
unzip ~/rpmbuild/SOURCES/%{name}-%{version}-linux-amd64.zip
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $?
|
||||
fi
|
||||
ls
|
||||
cd %{name}-%{version}-linux-amd64
|
||||
chown -R $USER.$USER .
|
||||
chmod -R a+rX,g-w,o-w .
|
||||
|
||||
%build
|
||||
rm -rf %{buildroot}
|
||||
|
||||
echo %{buildroot}
|
||||
|
||||
%install
|
||||
install -d -m 755 %{buildroot}/%{_sbindir}
|
||||
install -m 755 %{_builddir}/%{name}-%{version}-linux-amd64/centrifugo %{buildroot}/%{_sbindir}
|
||||
|
||||
install -d -m 755 %{buildroot}%{__prefix}/%{name}
|
||||
|
||||
install -d -m 755 %{buildroot}/%{_localstatedir}/log/%{name}
|
||||
install -d -m 755 %{buildroot}/%{_localstatedir}/lib/%{name}
|
||||
|
||||
install -d -m 755 %{buildroot}/%{_initrddir}
|
||||
install -m 755 %_sourcedir/%{name}.initd %{buildroot}/%{_initrddir}/%{name}
|
||||
|
||||
install -d -m 755 %{buildroot}/%{_sysconfdir}/security/limits.d/
|
||||
install -m 644 %_sourcedir/%{name}.nofiles.conf %{buildroot}/%{_sysconfdir}/security/limits.d/%{name}.nofiles.conf
|
||||
|
||||
install -d -m 755 %{buildroot}/%{_sysconfdir}/logrotate.d
|
||||
install -m 644 %_sourcedir/%{name}.logrotate %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}
|
||||
|
||||
install -d -m 755 %{buildroot}/%{_sysconfdir}/%{name}/
|
||||
install -m 644 %_sourcedir/%{name}.config.json %{buildroot}/%{_sysconfdir}/%{name}/config.json
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%pre
|
||||
getent group %{application_group} >/dev/null || groupadd -r %{application_group}
|
||||
getent passwd %{application_user} >/dev/null || /usr/sbin/useradd --comment "centrifugo Daemon User" --shell /bin/bash -M -r -g %{application_group} --home %{application_data} %{application_user}
|
||||
|
||||
%post
|
||||
chkconfig --add %{name}
|
||||
|
||||
%preun
|
||||
if [ $1 = 0 ]; then
|
||||
service %{name} stop > /dev/null 2>&1 || :
|
||||
chkconfig --del %{name}
|
||||
fi
|
||||
|
||||
%postun
|
||||
if [ $1 == 1 ] ; then
|
||||
service %{name} condrestart >/dev/null 2>&1 || :
|
||||
fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%{_sbindir}/%{name}
|
||||
%attr(0755,%{application_user},%{application_group}) %dir %{_localstatedir}/log/%{name}
|
||||
%attr(0755,%{application_user},%{application_group}) %dir %{_localstatedir}/lib/%{name}
|
||||
%{_initrddir}/%{name}
|
||||
%{__prefix}/%{name}
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/config.json
|
||||
%config(noreplace) %{_sysconfdir}/security/limits.d/%{name}.nofiles.conf
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
|
||||
Reference in New Issue
Block a user