Compare commits
1 Commits
dev
...
liveserver
Author | SHA1 | Date | |
---|---|---|---|
|
413ea33fe9 |
@ -1,20 +0,0 @@
|
|||||||
# FROM node:current-slim
|
|
||||||
FROM node:current-alpine
|
|
||||||
ARG VERSION
|
|
||||||
ENV VERSION ${VERSION:-development}
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY ./package*.json /app/
|
|
||||||
|
|
||||||
COPY ./Docker/cronjobs /etc/crontabs/root
|
|
||||||
|
|
||||||
COPY ./app /app/app
|
|
||||||
|
|
||||||
COPY ./libs /app/libs
|
|
||||||
|
|
||||||
COPY ./data /app/data
|
|
||||||
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
CMD ["crond", "-f", "-d", "8"]
|
|
@ -1,3 +0,0 @@
|
|||||||
0 * * * * echo "$(date '+%Y-%m-%d_%H%M%S')" 2>&1
|
|
||||||
10 15 * * 2,5 npm run predict 2>&1
|
|
||||||
45 9 * * 3,6 npm run retrieve 2>&1
|
|
@ -1,22 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "Predictor",
|
|
||||||
"script": "app/predict.js",
|
|
||||||
"env": {
|
|
||||||
"NODE_ENV": "production"
|
|
||||||
},
|
|
||||||
"autorestart": false,
|
|
||||||
"instances": 1,
|
|
||||||
"cron_restart": "10 15 * * 2,5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Retriever",
|
|
||||||
"script": "app/retriever.js",
|
|
||||||
"env": {
|
|
||||||
"NODE_ENV": "production"
|
|
||||||
},
|
|
||||||
"autorestart": false,
|
|
||||||
"instances": 1,
|
|
||||||
"cron_restart": "45 9 * * 3,6"
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
pm2-runtime start ecosystem.config.json --raw --env production
|
|
33
Makefile
33
Makefile
@ -1,33 +0,0 @@
|
|||||||
PROJECT = lot
|
|
||||||
VERSION = $(shell git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
ECR_REPO = mail.caliban.io:5000
|
|
||||||
#APP_IMAGE = 482681734622.dkr.ecr.eu-west-1.amazonaws.com/$(PROJECT):$(VERSION)
|
|
||||||
APP_IMAGE = $(ECR_REPO)/$(PROJECT):$(VERSION)
|
|
||||||
NO_CACHE = true
|
|
||||||
|
|
||||||
|
|
||||||
#build docker image
|
|
||||||
build:
|
|
||||||
docker build ./Docker/. -t $(APP_IMAGE) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE) --compress
|
|
||||||
.PHONY: build
|
|
||||||
|
|
||||||
#push docker image to registry
|
|
||||||
push: build
|
|
||||||
docker push $(APP_IMAGE)
|
|
||||||
.PHONY: push
|
|
||||||
|
|
||||||
#push docker image to registry
|
|
||||||
run: build
|
|
||||||
docker run $(APP_IMAGE)
|
|
||||||
.PHONY: run
|
|
||||||
ver:
|
|
||||||
@echo '$(VERSION)'
|
|
||||||
#echo $ERSION
|
|
||||||
.PHONY: ver
|
|
||||||
|
|
||||||
tar:
|
|
||||||
# docker build . -t $(APP_IMAGE) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE)
|
|
||||||
tar -C ./ -czvf ./archive.tar.gz 'package.json' 'ncas/' 'helpers/' -X *.js
|
|
||||||
|
|
||||||
.PHONY: build
|
|
@ -43,6 +43,3 @@ cron.schedule("45 9 * * 3,6", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
logger.info("Lot V3 started...");
|
logger.info("Lot V3 started...");
|
||||||
|
|
||||||
|
|
||||||
retrieveNew();
|
|
@ -1,31 +0,0 @@
|
|||||||
const loader = require('../libs/loader');
|
|
||||||
const lot = require('../libs/lot');
|
|
||||||
const lotv2 = require('../libs/lotV2');
|
|
||||||
const pusher = require('../libs/pusher');
|
|
||||||
const log4js = require('log4js');
|
|
||||||
const logger = log4js.getLogger();
|
|
||||||
|
|
||||||
logger.level = 'debug';
|
|
||||||
|
|
||||||
function run(data) {
|
|
||||||
const v1 = lot.calculate(data);
|
|
||||||
const v2 = lotv2.calculate(data);
|
|
||||||
|
|
||||||
const msg = `V2: ${v2} stars: ${v1.mainstars}
|
|
||||||
V1: ${v1.mainline} stars: ${v1.mainstars}
|
|
||||||
Other: ${v1.otherLine} stars: ${v1.otherStars}
|
|
||||||
`;
|
|
||||||
|
|
||||||
pusher.push(msg);
|
|
||||||
logger.debug(msg);
|
|
||||||
// loader.save(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
function go() {
|
|
||||||
logger.info('GO!');
|
|
||||||
loader.load(run);
|
|
||||||
}
|
|
||||||
|
|
||||||
(() => {
|
|
||||||
go();
|
|
||||||
})();
|
|
@ -1,5 +0,0 @@
|
|||||||
const { retrieveNew } = require('../libs/retriever');
|
|
||||||
|
|
||||||
(() => {
|
|
||||||
retrieveNew();
|
|
||||||
})();
|
|
File diff suppressed because one or more lines are too long
@ -1,11 +0,0 @@
|
|||||||
version: '3.5'
|
|
||||||
|
|
||||||
services:
|
|
||||||
lot:
|
|
||||||
container_name: Lot
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: ./Docker/Dockerfile
|
|
||||||
image: silvrtree-lot
|
|
||||||
volumes:
|
|
||||||
- ./data_store:/app/data
|
|
@ -5,21 +5,22 @@
|
|||||||
* Time: 16:35
|
* Time: 16:35
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const Pushover = require('node-pushover')/* , dateFormat = require('dateformat')*/;
|
var Pushover = require('node-pushover'), dateFormat = require('dateformat');
|
||||||
const push = new Pushover({
|
var push = new Pushover({
|
||||||
'token': 'aqnos2j4v4pjpry3hvnxq9646eup23', 'user': 'BE2vgFxdHJw91lVGMRYvZDDmVa5cCM'
|
'token': 'aqnos2j4v4pjpry3hvnxq9646eup23',
|
||||||
|
'user': 'BE2vgFxdHJw91lVGMRYvZDDmVa5cCM'
|
||||||
});
|
});
|
||||||
|
|
||||||
const logger = require('log4js').getLogger();
|
|
||||||
|
var logger = require('log4js').getLogger();
|
||||||
|
|
||||||
const prefix = process.env.NODE_ENV === 'production' ? 'Production' : 'Dev';
|
const prefix = process.env.NODE_ENV === 'production' ? 'Production' : 'Dev';
|
||||||
const title = `mdLot ${ prefix } Alert`;
|
const title = `mdLot ${ prefix } Alert`;
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
'push' : function(contents) {
|
'push' : function(contents) {
|
||||||
const now = new Date();
|
var now = new Date();
|
||||||
// var msg = `Updated at ${ dateFormat(now, 'dddd, mmmm dS, yyyy, HH:MM:ss') }\n\n${ contents }`;
|
var msg = `Updated at ${ dateFormat(now, 'dddd, mmmm dS, yyyy, HH:MM:ss') }\n\n${ contents }`;
|
||||||
const msg = `Updated at ${new Date(now).toLocaleString()}\n\n${contents}`;
|
|
||||||
push.send(title, msg);
|
push.send(title, msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,36 +1,30 @@
|
|||||||
const jsonfile = require('jsonfile');
|
const jsonfile = require("jsonfile");
|
||||||
|
|
||||||
const fetch = require('node-fetch');
|
const fetch = require("node-fetch");
|
||||||
const fecha = require('fecha');
|
const fecha = require("fecha");
|
||||||
|
|
||||||
const { scrapeResults } = require('./scraper');
|
const { scrapeResults } = require("./scraper");
|
||||||
|
|
||||||
const file = 'data/data.json';
|
const file = "data/data.json";
|
||||||
|
|
||||||
function lastEvent() {
|
// https://www.euro-millions.com/results
|
||||||
const dateThen = new Date();
|
|
||||||
|
|
||||||
// Tuesday and Friday
|
|
||||||
// Sun, Mon, *Tue*, Wed, Thu, *Fri*, Sat
|
|
||||||
// [2, 3 ,4 ,1 ,2 ,3 ,1]
|
|
||||||
|
|
||||||
const daySubtractor = [2, 3, 4, 1, 2, 3, 1];
|
|
||||||
|
|
||||||
const dayNow = dateThen.getDay();
|
|
||||||
|
|
||||||
dateThen.setDate(dateThen.getDate() - daySubtractor[dayNow]);
|
|
||||||
|
|
||||||
return fecha.format(dateThen, '/DD-MM-YYYY');
|
|
||||||
}
|
|
||||||
|
|
||||||
function retrieveNew() {
|
function retrieveNew() {
|
||||||
const ystring = lastEvent();
|
console.log("retrieveNew...");
|
||||||
|
const now = new Date().getTime();
|
||||||
|
|
||||||
|
// https://www.euro-millions.com/results/05-02-2019
|
||||||
|
|
||||||
|
const yesterday = new Date(now - 8.64e7);
|
||||||
|
|
||||||
|
const ystring = fecha.format(yesterday, "/DD-MM-YYYY");
|
||||||
|
|
||||||
const lotData = jsonfile.readFileSync(file);
|
const lotData = jsonfile.readFileSync(file);
|
||||||
|
|
||||||
const u = `https://www.euro-millions.com/results${ystring}`;
|
const u = `https://www.euro-millions.com/results${ystring}`;
|
||||||
|
|
||||||
console.log('retrieving:', u);
|
console.log("retrieving:", u);
|
||||||
|
|
||||||
|
// https://www.euro-millions.com/results/15-02-2019
|
||||||
|
|
||||||
fetch(u)
|
fetch(u)
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
|
6303
package-lock.json
generated
6303
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -6,16 +6,14 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "node lot.js",
|
"start": "node lot.js",
|
||||||
"retrieve": "node ./app/retriever.js",
|
"retrieve": "node app.js"
|
||||||
"predict" : "node ./app/predict.js"
|
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.15.0",
|
"jsonfile": "^2.2.3",
|
||||||
"jsonfile": "^6.1.0",
|
"node-cron": "^1.0.0",
|
||||||
"node-cron": "^3.0.0",
|
"tape": "^4.9.2",
|
||||||
"tape": "^5.5.3",
|
|
||||||
"tape-promise": "^4.0.0",
|
"tape-promise": "^4.0.0",
|
||||||
"ultrases": "^0.1.3"
|
"ultrases": "^0.1.3"
|
||||||
},
|
},
|
||||||
@ -24,10 +22,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^1.0.0-rc.2",
|
"cheerio": "^1.0.0-rc.2",
|
||||||
"fecha": "^4.2.3",
|
"dateformat": "^2.0.0",
|
||||||
"log4js": "^6.4.6",
|
"fecha": "^3.0.2",
|
||||||
|
"jsonfile": "^2.4.0",
|
||||||
|
"log4js": "^2.3.3",
|
||||||
"node-fetch": "^2.3.0",
|
"node-fetch": "^2.3.0",
|
||||||
"node-pushover": "^1.0.0",
|
"node-pushover": "^0.2.2",
|
||||||
"sugar": "^2.0.1",
|
"sugar": "^2.0.1",
|
||||||
"sugar-date": "^2.0.0"
|
"sugar-date": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,14 @@
|
|||||||
* Time: 16:35
|
* Time: 16:35
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
var Pushover = require('node-pushover')/*, dateFormat = require('dateformat')*/;
|
var Pushover = require('node-pushover'), dateFormat = require('dateformat');
|
||||||
var push = new Pushover({
|
var push = new Pushover({
|
||||||
'token': 'aqnos2j4v4pjpry3hvnxq9646eup23',
|
'token': 'aqnos2j4v4pjpry3hvnxq9646eup23',
|
||||||
'user': 'BE2vgFxdHJw91lVGMRYvZDDmVa5cCM'
|
'user': 'BE2vgFxdHJw91lVGMRYvZDDmVa5cCM'
|
||||||
});
|
});
|
||||||
|
|
||||||
const logger = require('log4js').getLogger();
|
|
||||||
|
var logger = require('log4js').getLogger();
|
||||||
|
|
||||||
const prefix = process.env.NODE_ENV === 'production' ? 'Production' : 'Dev';
|
const prefix = process.env.NODE_ENV === 'production' ? 'Production' : 'Dev';
|
||||||
const title = `mdLot ${ prefix } Alert`;
|
const title = `mdLot ${ prefix } Alert`;
|
||||||
@ -19,8 +20,7 @@ module.exports = {
|
|||||||
|
|
||||||
'push' : function(contents) {
|
'push' : function(contents) {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
// var msg = `Updated at ${ dateFormat(now, 'dddd, mmmm dS, yyyy, HH:MM:ss') }\n\n${ contents }`;
|
var msg = `Updated at ${ dateFormat(now, 'dddd, mmmm dS, yyyy, HH:MM:ss') }\n\n${ contents }`;
|
||||||
var msg = `Updated at ${ now.format(('dddd, mmmm dS, yyyy, HH:MM')) }\n\n${ contents }`;
|
|
||||||
push.send(title, msg);
|
push.send(title, msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user