1 | #!/bin/bash
|
---|
2 | set -e
|
---|
3 | if [[ -z "$1" ]]; then
|
---|
4 | echo -e "What is the path to the Web2Py install? : \c "
|
---|
5 | read WEB2PY
|
---|
6 | else
|
---|
7 | WEB2PY=$1
|
---|
8 | fi
|
---|
9 | if [[ -z "$2" ]]; then
|
---|
10 | echo -e "What is the Applicaton Name? : \c "
|
---|
11 | read APPNAME
|
---|
12 | else
|
---|
13 | APPNAME=$2
|
---|
14 | fi
|
---|
15 | if [[ -z "$3" ]]; then
|
---|
16 | echo -e "What license-key should we use? : \c "
|
---|
17 | read LICENSE
|
---|
18 | else
|
---|
19 | LICENSE=$3
|
---|
20 | fi
|
---|
21 |
|
---|
22 | # App Monitoring
|
---|
23 | apt-get install -y python-pip
|
---|
24 | pip install newrelic
|
---|
25 |
|
---|
26 | cd $WEB2PY
|
---|
27 | newrelic-admin generate-config $LICENSE newrelic.ini
|
---|
28 | sed -i "s|Python Application|$APPNAME|" $WEB2PY/newrelic.ini
|
---|
29 | #sed -i "s|#log_file|log_file|" $WEB2PY/newrelic.ini
|
---|
30 |
|
---|
31 | sed -i "/^import gluon.main$/i \
|
---|
32 | import newrelic.agent\n\
|
---|
33 | newrelic.agent.initialize('newrelic.ini')\n\
|
---|
34 | " $WEB2PY/wsgihandler.py
|
---|
35 |
|
---|
36 | sed -i "/^<\/uwsgi>$/i \
|
---|
37 | <enable-threads\/>\n\
|
---|
38 | <single-interpreter\/>\n\
|
---|
39 | <lazy-apps\/>" $WEB2PY/uwsgi.xml
|
---|
40 |
|
---|
41 | /etc/init.d/uwsgi-prod restart
|
---|
42 |
|
---|
43 | # Server Monitoring
|
---|
44 | cat << EOF > "/etc/apt/sources.list.d/newrelic.list"
|
---|
45 | deb http://apt.newrelic.com/debian/ newrelic non-free
|
---|
46 | EOF
|
---|
47 | wget -O- http://download.newrelic.com/548C16BF.gpg | apt-key add -
|
---|
48 | apt-get update
|
---|
49 | apt-get install newrelic-sysmond
|
---|
50 | nrsysmond-config --set license_key=$LICENSE
|
---|
51 | /etc/init.d/newrelic-sysmond start
|
---|