Skip to content

Crashes when trying to daemonize #13

Description

@SlowBro904

This works:

(mypy) root@ubuntu:/mypy# export PYTHONPATH=/mypy; /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
redis initialized 127.0.0.1 6379

AUTH: user=admin, password matches = True
ACL: user=admin topic=mypy/d256cc9e/ping, matches = True

(mypy) root@ubuntu:/mypy# mosquitto_pub -t 'admin/d256cc9e/ping' -m 'ack' -u 'admin' -P 'password' -I 'd256cc9e' -h mqtt01 -p 8883 --cafile /mypy/certs/ca.crt
(mypy) root@ubuntu:/mypy#
(mypy) root@ubuntu:/mypy# mosquitto_sub -t 'admin/d256cc9e/ping' -u 'admin' -P 'password' -I 'd256cc9e' -h mqtt01 -p 8883 --cafile /mypy/certs/ca.crt

ack

However, running from /etc/init.d fails, and yes I did add the PYTHONPATH variable. NO log error messages, despite every log_type enabled in mosquitto.conf. And mosquitto works without the plugin.

I am on Ubuntu 17.10 and I downloaded the latest mosquitto_pyauth code from github last night. The make options were USE_CARES=1 PYTHON_VERSION=3.6. I am using the example redis_auth.py. Mosquitto version 1.4.12.

(mypy) root@ubuntu:/mypy# grep -C5 PYTHONPATH /etc/init.d/mosquitto
run_by_init() {
    ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
}

export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
export PYTHONPATH="${PYTHONPATH}:/mypy"

case "$1" in
  start)
        if init_is_upstart; then
            exit 1
(mypy) root@ubuntu:/mypy# /etc/init.d/mosquitto restart
Restarting mosquitto (via systemctl): mosquitto.service.
(mypy) root@ubuntu:/mypy# ps -ef | grep -i mosq
root     12679 12669  0 02:26 pts/3    00:00:06 tail -f /var/log/mosquitto/mosquitto.log
root     28560 24666  1 10:13 pts/8    00:00:00 vi /etc/init.d/mosquitto
mosquit+ 28641     1  2 10:13 ?        00:00:00 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
root     28646 24653  0 10:13 pts/7    00:00:00 grep --color=auto -i mosq
(mypy) root@ubuntu:/mypy# mv /etc/mosquitto/conf.d/pyauth.conf.disabled /etc/mosquitto/conf.d/pyauth.conf
(mypy) root@ubuntu:/mypy# /etc/init.d/mosquitto restart                                                Restarting mosquitto (via systemctl): mosquitto.service.
(mypy) root@ubuntu:/mypy# ps -ef | grep -i mosq                                                        root     12679 12669  0 02:27 pts/3    00:00:06 tail -f /var/log/mosquitto/mosquitto.log
root     28560 24666  0 10:13 pts/8    00:00:00 vi /etc/init.d/mosquitto
root     28687 24653  2 10:14 pts/7    00:00:00 grep --color=auto -i mosq
(mypy) root@ubuntu:/mypy# /etc/init.d/mosquitto restart
Restarting mosquitto (via systemctl): mosquitto.service.
(mypy) root@ubuntu:/mypy# ps -ef | grep -i mosq
root     28560 24666  0 10:13 pts/8    00:00:00 vi /etc/init.d/mosquitto
root     28693 12669  0 10:14 pts/3    00:00:00 tail -f /var/log/mosquitto/mosquitto.log
root     28735 24653  0 10:14 pts/7    00:00:00 grep --color=auto -i mosq
(mypy) root@ubuntu:/mypy# cat /etc/mosquitto/conf.d/pyauth.conf
auth_plugin /usr/lib/mosquitto_pyauth/auth_plugin_pyauth.so
auth_opt_pyauth_module redis_auth
(mypy) root@ubuntu:/mypy# tail /var/log/mosquitto/mosquitto.log
1524752004: New client connected from 10.0.2.2 as d256cc9e (c1, k60, u'admin').
1524752004: Sending CONNACK to d256cc9e (0, 0)
1524752004: Received PUBLISH from d256cc9e (d0, q1, r1, m601, 'admin/d256cc9e/user_op', ... (34 bytes))
1524752004: Sending PUBACK to d256cc9e (Mid: 601)
1524752046: Error in poll: Interrupted system call.
1524752046: mosquitto version 1.4.12 terminating
1524752047: mosquitto version 1.4.12 (build date Thu, 01 Mar 2018 09:24:46 -0500) starting
1524752047: Config loaded from /etc/mosquitto/mosquitto.conf.
1524752075: mosquitto version 1.4.12 (build date Thu, 01 Mar 2018 09:24:46 -0500) starting
1524752075: Config loaded from /etc/mosquitto/mosquitto.conf.
(mypy) root@ubuntu:/mypy# grep log /etc/mosquitto/mosquitto.conf
log_dest file /var/log/mosquitto/mosquitto.log
log_type all
log_type debug
log_type error
log_type warning
log_type notice
log_type information
log_type subscribe
log_type unsubscribe
log_type websockets
(mypy) root@ubuntu:/mypy#

Oddly, if I copy the init script into my current working directory, it works. So I don't see what's different about using the init script in /etc/init.d. Maybe some environment variable? Something about the interaction between systemd and this plugin?

(mypy) root@ubuntu:/mypy# ./mosquitto.init.d.sh start
 * Starting network daemon: mosquitto
   ...done.
(mypy) root@ubuntu:/mypy# ps -ef | grep -i mosq
root     28693 12669  0 10:32 pts/3    00:00:00 tail -f /var/log/mosquitto/mosquitto.log
root     28802 28771  0 10:46 pts/4    00:00:01 mosquitto_sub -t admin/d256cc9e/ping -u admin -P password -I d256cc9e -h mqtt01 -p 8883 --cafile /mypy/certs/ca.crt
root     29142 28785  1 11:00 pts/5    00:00:00 vim mosquitto.init.d.sh
mosquit+ 29180     1 32 11:01 ?        00:00:00 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
root     29183 24666  2 11:01 pts/8    00:00:00 grep --color=auto -i mosq
(mypy) root@ubuntu:/mypy#

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions