Skip to content
This repository was archived by the owner on Aug 30, 2020. It is now read-only.

Commit 67ba3d4

Browse files
author
Hongze Xia
committed
update readme
1 parent 2c8893b commit 67ba3d4

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

README.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ Welcome to Price-Tracker. Hope you could save money with this little app. This p
66

77
Given an `xpath` and a link, one could extract price information from the website. Although `xpath` and the link could become invalid at anytime, we could still hope for the best and track down the trend for the price of interest.
88

9+
## Requirements
10+
11+
Starting from v0.3.0, this project relies on an external API call [pushover](https://pushover.net/) which pushes notifications directly to your phones or desktops. The app is about 5USD which is worth the money in my view as you get neat messages right there on your phone. Also, you could build as many as app with their service if you like.
12+
13+
After setting up your pushover account, you need to create an app for this application. Then,
14+
you got two tokens, one for your user account and one for the app. That is it.
15+
16+
For the each record in datastore, you could overwrite the user and the device key such that
17+
your messages are only delivered to specific persons or devices. By default, the app would send
18+
messages to all devices in your account.
19+
920
## Build
1021

1122
Dependencies:
@@ -19,12 +30,6 @@ In the project directory, run
1930
go build
2031
```
2132

22-
## Important fix in chromedp
23-
24-
In `vendor/github.com/chromedp/chromedp/runner/runner.go:248`, change to `if r.cmd != nil && r.cmd.Process != nil {` as chromium did not shutdown properly and there is no harm sending signalterm anyway.
25-
26-
Comment out `vendor/github.com/chromedp/chromedp/runner/runner.go:11`.
27-
2833
## Setup and Serve
2934

3035
Once you have compiled this project, a binary executable named `pricetracker` should be sitting in your directory. There are some important environment variables that you want to setup before running it.
@@ -36,26 +41,38 @@ To setup environment variables, do
3641
```bash
3742
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/gcp/credential.json"
3843
export CHROME_TIMEOUT=60 # in seconds
44+
$ ./pricetracker -h
45+
Usage of ./pricetracker:
46+
-appToken string
47+
pushover app token
48+
-fetchLimit int
49+
fetch limit from google datastore (default 10)
50+
-port string
51+
server port (default "8080")
52+
-schdlFreq int
53+
schedule frequency in minutes (default 2)
54+
-userToken string
55+
pushover user token
56+
# appToken and userToken are required!
3957
```
4058

41-
and then simply run, `./pricetracker`. Well done! You make it.
42-
43-
## Daemonization
44-
45-
You can do better by making this little app run as a daemon in Linux by,
59+
## Put It in One Script
4660

4761
```bash
4862
#!/bin/bash
4963

64+
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/gcp/credential.json"
65+
export CHROME_TIMEOUT=60 # in seconds
66+
5067
WDIR=/home/pi/apps/pricetracker
5168

52-
source ${WDIR}/.env && daemon --name="pricetracker" --output=${WDIR}/log ${WDIR}/pricetracker
69+
${WDIR}/pricetracker \
70+
-appToken APPTOKEN \
71+
-userToken USERTOKEN \
72+
-schdlFreq 10 \
73+
-fetchLimit 10
5374
```
5475

55-
where `.env` is the environment variables (saved as a file) we set in the last step.
56-
57-
Of course, you need `daemon` for this script to work.
58-
5976
## Logrotation
6077

6178
We could also rotate the log by setting up a cron job like,

0 commit comments

Comments
 (0)