]> source.dussan.org Git - rspamd.git/commitdiff
Add systemd unit
authorMikhail Gusarov <dottedmag@dottedmag.net>
Fri, 28 Mar 2014 14:51:16 +0000 (15:51 +0100)
committerMikhail Gusarov <dottedmag@dottedmag.net>
Sat, 29 Mar 2014 09:36:57 +0000 (10:36 +0100)
CMakeLists.txt
debian/control
debian/logging.conf [new file with mode: 0644]
debian/rspamd.install [new file with mode: 0644]
debian/rules
debian/workers.conf [new file with mode: 0644]
rspamd.service [new file with mode: 0644]
rspamd.socket [new file with mode: 0644]

index 211bf957991316415a2539d2c83fcd0b10173146..b100f1525dab3a26570d1cf10312920481333c94 100644 (file)
@@ -91,6 +91,10 @@ IF(NOT INCLUDEDIR)
        SET(INCLUDEDIR include/rspamd)
 ENDIF(NOT INCLUDEDIR)
 
+IF(NOT SYSTEMDDIR)
+       SET(SYSTEMDDIR ${CMAKE_INSTALL_PREFIX}/lib/systemd/system)
+ENDIF(NOT SYSTEMDDIR)
+
 ############################# INCLUDE SECTION #############################################
 
 INCLUDE(CheckIncludeFiles)
@@ -1015,6 +1019,11 @@ FOREACH(LUA_CONF ${LUA_CONFIGS})
        INSTALL(FILES "conf/lua/${LUA_CONF}" DESTINATION ${CONFDIR}/lua/${_rp})
 ENDFOREACH(LUA_CONF)
 
+# systemd unit
+
+INSTALL(FILES "rspamd.service" DESTINATION ${SYSTEMDDIR})
+INSTALL(FILES "rspamd.socket" DESTINATION ${SYSTEMDDIR})
+
 # Manual pages
 INSTALL(FILES "doc/rspamd.8" DESTINATION ${MANDIR}/man8)
 INSTALL(FILES "doc/rspamc.1" DESTINATION ${MANDIR}/man1)
index e89f26946712f2c1d68cbeef18d5987d8444bf11..f830056718dc9ffec7078a3e34832a8ca4308e9d 100644 (file)
@@ -2,7 +2,7 @@ Source: rspamd
 Section: mail
 Priority: optional
 Maintainer: Mikhail Gusarov <dottedmag@debian.org>
-Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.16.1~), cmake, libevent-dev (>= 1.3), libglib2.0-dev (>= 2.16.0), libgmime-2.6-dev, liblua5.2-dev | liblua5.1-dev | liblua5.1-0-dev, libpcre3-dev, libssl-dev (>= 1.0), libcurl4-openssl-dev, libhiredis-dev
+Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.16.1~), cmake, libevent-dev (>= 1.3), libglib2.0-dev (>= 2.16.0), libgmime-2.6-dev, liblua5.2-dev | liblua5.1-dev | liblua5.1-0-dev, libpcre3-dev, libssl-dev (>= 1.0), libcurl4-openssl-dev, libhiredis-dev, dh-systemd
 Standards-Version: 3.9.5
 Homepage: https://rspamd.com
 Vcs-Git: git://github.com/vstakhov/rspamd.git
diff --git a/debian/logging.conf b/debian/logging.conf
new file mode 100644 (file)
index 0000000..33234fd
--- /dev/null
@@ -0,0 +1,4 @@
+logging {
+    type = "console";
+    level = "info";
+}
diff --git a/debian/rspamd.install b/debian/rspamd.install
new file mode 100644 (file)
index 0000000..f02b35d
--- /dev/null
@@ -0,0 +1,2 @@
+debian/workers.conf etc/rspamd
+debian/logging.conf etc/rspamd
index be4ab6e11a381e1ec97d33d4394401d6e9a31254..fbb555cb31cc60a9b688714a4e8bbe8a4f2fd470 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/make -f
 %:
-       dh $@
+       dh $@ --with systemd
 
 export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
 # Until https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739834 is fixed
@@ -29,3 +29,6 @@ override_dh_auto_clean:
 override_dh_fixperms:
        dh_fixperms
        chmod 750 $(CURDIR)/debian/rspamd/var/lib/rspamd
+
+override_dh_systemd_start:
+       dh_systemd_start --restart-after-upgrade
diff --git a/debian/workers.conf b/debian/workers.conf
new file mode 100644 (file)
index 0000000..1d59010
--- /dev/null
@@ -0,0 +1,19 @@
+worker {
+    type = "normal";
+    bind_socket = "systemd:0";
+    http = false;
+    allow_learn = true;
+    mime = true;
+}
+worker {
+    type = "controller";
+    bind_socket = "systemd:1";
+    count = 1;
+}
+worker {
+    type = "webui";
+    count = 1;
+    bind_socket = "systemd:2";
+    password = "q1";
+    secure_ip = "127.0.0.1";
+}
diff --git a/rspamd.service b/rspamd.service
new file mode 100644 (file)
index 0000000..ff9655b
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=rapid spam filtering system
+
+[Service]
+Type=simple
+# Replace Pre/Post with RuntimeDirectory once it is available
+PermissionsStartOnly=true
+ExecStartPre=/bin/mkdir -m700 -p /run/rspamd
+ExecStartPre=/bin/chown _rspamd:_rspamd /run/rspamd
+ExecStart=/usr/bin/rspamd -f -c /etc/rspamd/rspamd.conf
+ExecReload=/bin/kill -HUP $MAINPID
+ExecStopPost=/bin/rm -r /run/rspamd
+WorkingDirectory=/var/lib/rspamd
+User=_rspamd
diff --git a/rspamd.socket b/rspamd.socket
new file mode 100644 (file)
index 0000000..e326ddd
--- /dev/null
@@ -0,0 +1,11 @@
+[Unit]
+Description=rapid spam filtering system
+
+[Socket]
+ListenStream=11333
+ListenStream=127.0.0.1:11334
+ListenStream=127.0.0.1:11336
+FreeBind=true
+
+[Install]
+WantedBy=sockets.target