Skip to content

Commit db3dace

Browse files
Merge pull request #175 from gregcorbett/issue-80
Remove python-daemon as a hard requirement
2 parents 213a9cc + f815708 commit db3dace

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,17 @@ The Python STOMP library (N.B. versions between 3.1.1 (inclusive) and 5.0.0
4040

4141
The Python AMS library. This is only required if you want to use AMS. See here for details on obtaining an RPM: https://github.com/ARGOeu/argo-ams-library/
4242

43-
The Python daemon library
44-
* `yum install python-daemon`
45-
4643
The Python ldap library
4744
* `yum install python-ldap`
4845

4946
Optionally, the Python dirq library (N.B. this is only required if your messages
5047
are stored in a dirq structure)
5148
* `yum install python-dirq`
5249

50+
The Python daemon library (N.B. installing this library is only required when
51+
using the SSM as a receiver)
52+
* `yum install python-daemon`
53+
5354
You need a certificate and key in PEM format accessible to the SSM.
5455
There are a number of ways to do this. One is to make a copy of the
5556
hostcert and hostkey files, owned by the apel user (created later):

apel-ssm.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BuildArch: noarch
2121
BuildRequires: python-devel
2222
%endif
2323

24-
Requires: stomppy < 5.0.0, python-daemon, python-ldap, openssl
24+
Requires: stomppy < 5.0.0, python-ldap, openssl
2525
Requires(pre): shadow-utils
2626

2727
%define ssmconf %_sysconfdir/apel

ssm/agents.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from __future__ import absolute_import, division, print_function, unicode_literals
2020

21-
from daemon import DaemonContext
2221
import logging
2322
import ldap
2423
import os
@@ -30,6 +29,13 @@
3029
except ImportError:
3130
import configparser as ConfigParser
3231

32+
try:
33+
from daemon import DaemonContext
34+
except ImportError:
35+
# A error is logged and the receiver exits later if DaemonContext is
36+
# requested but not installed.
37+
DaemonContext = None
38+
3339
from stomp.exception import NotConnectedException
3440
try:
3541
from argo_ams_library import AmsConnectionException
@@ -259,6 +265,13 @@ def run_sender(protocol, brokers, project, token, cp, log):
259265

260266
def run_receiver(protocol, brokers, project, token, cp, log, dn_file):
261267
"""Run Ssm2 as a receiver daemon."""
268+
if DaemonContext is None:
269+
log.error("Receiving SSMs must use python-daemon, but the "
270+
"python-daemon module wasn't found.")
271+
log.error("System will exit.")
272+
log.info(LOG_BREAK)
273+
sys.exit(1)
274+
262275
log.info('The SSM will run as a daemon.')
263276

264277
# We need to preserve the file descriptor for any log files.

0 commit comments

Comments
 (0)