Ads 468x60px

##EasyReadMore##

17 5月, 2016

[Quark] 將程式加入 daemon for MQtt

//check have /usr/sbin/mosquitto and just service no start
//add service when system start

cd /etc/init.d
vi mqtt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
#
test -f /usr/sbin/mosquitto || exit 0
test -f /etc/mosquitto/conf.d || exit 0
case "$1" in
        start )
                echo -n "Starting MQTT Server: "
                /usr/sbin/mosquitto -c /etc/mosquitto/conf.d -d  > /dev/null 2>&1 &
        if [ "$?" = "0" ]; then
                    echo " [ OK ]"
                else
                    echo " [ Fail ]"
                fi
                ;;
        stop )
                echo -n "Stopping MQTT Server: "
                kill -s 9 `pidof mosquitto` > /dev/null 2>&1
                sleep 2
                tr=`ps aux | grep 'mosquitto' | grep -v grep`
                if [ "x$tr" = "x" ]; then
                    echo " [ OK ]"
                else
                    echo " [ Fail ]"
                fi
                ;;
        restart )
                $0 stop
                sleep 2
                $0 start
                if [ "$?" != "0" ]; then
                        exit 1
                fi
                ;;
        *)
                echo "Usage: /etc/init.d/mqtt {start|stop|restart}"
                exit 1
esac

exit 0
cp mosquitto.conf conf.d

vi conf.d to fix below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//fix felow
retry_interval 20
sys_interval 10
store_clean_interval 10
pid_file /var/run/mosquitto.pid
user root
max_inflight_messages 20
max_queued_messages 100

//mark below
#listener 1883

#listener 9002
#protocol websockets
#certfile /etc/nginx/ssl/ssl-cert-snakeoil.pem
#keyfile /etc/nginx/ssl/ssl-cert-snakeoil.key

#listener 9001
#protocol websockets

./mqtt start
./mqtt stop

0 意見:

張貼留言

 
Blogger Templates