Configuring the Raspberry Pi agent to run as a service

revert-dabc3590
savi_wso2 8 years ago
parent 431c099bdb
commit 8075d7cb32

@ -15,7 +15,7 @@ DESC="This service is used to publish events from the Raspberry Pi to the WSO2 D
NAME=RaspberryStats NAME=RaspberryStats
DIR=/usr/local/src/RaspberryAgent/src/ DIR=/usr/local/src/RaspberryAgent/src/
DAEMON=python $DIR/RaspberryAgent.py DAEMON=$DIR/RaspberryAgent.py
DAEMON_NAME=$NAME DAEMON_NAME=$NAME
SCRIPTNAME=RaspberryService.sh SCRIPTNAME=RaspberryService.sh
@ -39,6 +39,7 @@ DAEMON_USER=root #pi
do_start () { do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon" log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
python $DAEMON &
log_end_msg $? log_end_msg $?
} }
do_stop () { do_stop () {

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin python
""" """
/** /**
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
@ -23,7 +23,8 @@ import logging, logging.handlers
import sys, os, signal, argparse import sys, os, signal, argparse
import running_mode import running_mode
import time, threading, datetime, calendar import time, threading, datetime, calendar
import iotUtils, mqttConnector, Adafruit_DHT, httpServer import iotUtils, mqttConnector, httpServer
import Adafruit_DHT
# import httplib, ssl # import httplib, ssl
# from functools import wraps # from functools import wraps

@ -46,9 +46,9 @@ sudo python Adafruit_Python_DHT/setup.py install
sudo cp $currentDir/deviceConfig.properties $currentDir/src sudo cp $currentDir/deviceConfig.properties $currentDir/src
sudo cp -r $currentDir/src $destination sudo cp -r $currentDir/src $destination
sudo chmod +x $destination/src/RaspberryAgent.py sudo chmod 755 $destination/src/RaspberryAgent.py
sudo update-rc.d -f RaspberryService.sh remove sudo update-rc.d -f RaspberryService.sh remove
sudo cp $currentDir/RaspberryService.sh /etc/init.d sudo cp $currentDir/RaspberryService.sh /etc/init.d
sudo chmod +x /etc/init.d/RaspberryService.sh sudo chmod 755 /etc/init.d/RaspberryService.sh
sudo update-rc.d RaspberryService.sh defaults sudo update-rc.d RaspberryService.sh defaults
sudo service RaspberryService.sh start sudo service RaspberryService.sh start

Loading…
Cancel
Save