Skip to content

Commit

Permalink
Added startup script and gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
th0m committed Dec 14, 2014
1 parent f9c93a7 commit dc250fe
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
db
log
11 changes: 9 additions & 2 deletions back.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python2
import bs4 as BeautifulSoup
import requests
import logging
import smtplib
import redis
import hashlib
import json
import time
from jinja2 import Environment, FileSystemLoader
from email.mime.text import MIMEText
from pymongo import MongoClient
Expand Down Expand Up @@ -93,7 +95,7 @@ def crawl(alert):
return content

def sendMail(mail, alertName, content):
env = Environment(loader=FileSystemLoader('templates'))
env = Environment(loader=FileSystemLoader('/home/tennis/templates'))
template = env.get_template('mail.html')
output = template.render(content=content)
msg = MIMEText(output, 'html', 'utf-8')
Expand Down Expand Up @@ -122,4 +124,9 @@ def check_alerts():
rdb = redis.Redis('localhost')
s = requests.Session()
login('171091026', '5434')
check_alerts()
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
while True:
logging.info('check_alerts() started')
check_alerts()
logging.info('check_alerts() ended')
time.sleep(60)
2 changes: 1 addition & 1 deletion rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ def get_user():

if __name__ == '__main__':
db = MongoClient().tennis
app.run(host='0.0.0.0',debug=True)
app.run(debug=True)
12 changes: 12 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
export LANG=en_US.UTF-8
echo Start Mongo
mongod --fork --logpath /home/tennis/log/mongo.log
echo Start Redis
redis-server > /home/tennis/log/redis.log &
echo Start Postfix
postfix start
echo Start Rest
/home/tennis/rest.py > /home/tennis/log/rest.log &
echo Start Back
/home/tennis/back.py > /home/tennis/log/back.log

0 comments on commit dc250fe

Please sign in to comment.