Commit ed2bff8e authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 6305277d
Pipeline #53 canceled with stages
...@@ -5,7 +5,7 @@ const shellExec = require('shell-exec') ...@@ -5,7 +5,7 @@ const shellExec = require('shell-exec')
const cron = require('node-cron'); const cron = require('node-cron');
const express = require('express') const express = require('express')
const app = express() const app = express()
const port = 3000 const port = 80
let moment = require('moment-timezone') let moment = require('moment-timezone')
const connectionString = 'postgresql://ibs:secretpassword@51.91.150.227:5432/IBSng' const connectionString = 'postgresql://ibs:secretpassword@51.91.150.227:5432/IBSng'
const client = new Client({ const client = new Client({
...@@ -21,8 +21,13 @@ app.get('/', (req, res) => { ...@@ -21,8 +21,13 @@ app.get('/', (req, res) => {
res.sendfile('config.mobileconfig') res.sendfile('config.mobileconfig')
}) })
async function refresh() { async function refresh() {
try {
await client.connect() await client.connect()
}
catch (e) {
}
let res = await client.query('select * from users As u,normal_users As n,user_attrs AS att where u.user_id=n.user_id and att.user_id=u.user_id and group_id=1') let res = await client.query('select * from users As u,normal_users As n,user_attrs AS att where u.user_id=n.user_id and att.user_id=u.user_id and group_id=1')
...@@ -53,10 +58,18 @@ async function refresh() { ...@@ -53,10 +58,18 @@ async function refresh() {
await createfile(last) await createfile(last)
await execLast() await execLast()
try {
await client.end() await client.end()
}
catch (e) {
}
} }
cron.schedule(' */30 * * * * *', () => { cron.schedule(' */30 * * * * *', () => {
return refresh() return refresh()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment