Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gbpservice/contrib/nfp/tools/image_builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ RUN cp /usr/local/lib/python2.7/dist-packages/gbpservice/nfp/bin/nfp /usr/bin/
RUN chmod +x /usr/bin/nfp
RUN cp /usr/local/lib/python2.7/dist-packages/gbpservice/contrib/nfp/bin/nfp_configurator.ini /etc/
RUN cp /usr/local/lib/python2.7/dist-packages/gbpservice/contrib/nfp/bin/policy.json /etc/
RUN cp /group-based-policy/gbpservice/contrib/nfp/tools/image_builder/nfp-controller /etc/init.d/
RUN cp /group-based-policy/gbpservice/contrib/nfp/tools/image_builder/nfp-pecan /etc/init.d/
RUN mkdir -p /var/log/nfp
RUN touch /var/log/nfp/nfp_configurator.log
RUN touch /var/log/nfp/nfp_pecan.log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

service rabbitmq-server start
screen -dmS "configurator" /usr/bin/python2 /usr/bin/nfp --config-file=/etc/nfp_configurator.ini --log-file=/var/log/nfp/nfp_configurator.log
service nfp-controller start
cd /usr/local/lib/python2.7/dist-packages/gbpservice/nfp/pecan/api/
python setup.py develop
screen -dmS "pecan" pecan configurator_decider config.py --mode advanced
service nfp-pecan start
/bin/bash

38 changes: 38 additions & 0 deletions gbpservice/contrib/nfp/tools/image_builder/nfp-controller
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
PID_FILE=/var/run/nfp_controller.pid

start_nfp_controller () {
exec start-stop-daemon --quiet --start -m --pidfile $PID_FILE --background --exec /usr/bin/python2 /usr/bin/nfp -- --log-file /var/log/nfp/nfp_configurator.log --config-file /etc/nfp_configurator.ini
}

stop_nfp_controller () {
exec start-stop-daemon --quiet --stop --signal KILL --pidfile $PID_FILE
}

status_nfp_controller () {
set +e
wc=`ps -elf|grep nfp |wc -l`
if [ $wc -le 3 ] ; then
echo "nfp controller is NOT running"
else
echo "nfp controller is running"
fi
}


case "$1" in
start)
start_nfp_controller
;;
stop)
stop_nfp_controller
;;
status)
status_nfp_controller
;;
*)
echo "Usage: $0 {start|stop|status}" >&2
RETVAL=1
;;
esac

39 changes: 39 additions & 0 deletions gbpservice/contrib/nfp/tools/image_builder/nfp-pecan
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
#
PID_FILE=/var/run/nfp_pecan.pid

start_nfp_pecan () {
exec start-stop-daemon --quiet --start -m --pidfile $PID_FILE --background --chdir /usr/local/lib/python2.7/dist-packages/gbpservice/nfp/pecan/api --exec /usr/local/bin/pecan configurator_decider config.py -- --mode advanced
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can systemctl be used to start/stop?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.
configurator docker is ubuntu image.Since Ubuntu doesn't use systemd.
systemctl is only for RHEL.


stop_nfp_pecan () {
exec start-stop-daemon --quiet --stop --signal KILL --pidfile $PID_FILE
}

status_nfp_pecan () {
set +e
wc=`ps -elf|grep pecan |wc -l`
if [ $wc -le 3 ] ; then
echo "nfp pecan is NOT running"
else
echo "nfp pecan is running"
fi
}

case "$1" in
start)
start_nfp_pecan
;;
stop)
stop_nfp_pecan
;;
status)
status_nfp_pecan
;;
*)
echo "Usage: $0 {start|stop|status}" >&2
RETVAL=1
;;
esac