6 Commits

Author SHA1 Message Date
66d68701c2 Revert "В репе конфиг не нужен"
Some checks failed
continuous-integration/drone/push Build is failing
Все пошло не так

This reverts commit 0ba3b5f037.
2021-11-01 05:13:35 +03:00
94a626e7f1 Не будем пробрасывать конфиг (а нужно ли его вытаскивать наружу?)
All checks were successful
continuous-integration/drone/push Build is passing
2021-11-01 05:07:50 +03:00
0ba3b5f037 В репе конфиг не нужен
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone Build is failing
2021-11-01 05:02:12 +03:00
7544e3c447 Добавил конфигурацию самого приложения
Some checks failed
continuous-integration/drone/push Build is failing
2021-11-01 04:58:13 +03:00
96790be6f7 Вернул метрики
All checks were successful
continuous-integration/drone/push Build is passing
2021-11-01 04:46:07 +03:00
89dcffa6bb Merge pull request 'prometheus-monitoring' (#3) from prometheus-monitoring into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: http://git.lulzette.ru/lulzette/pycms/pulls/3
2021-11-01 04:40:18 +03:00
3 changed files with 24 additions and 4 deletions

View File

@@ -4,8 +4,6 @@ services:
build: . build: .
ports: ports:
- 8080:8080 - 8080:8080
volumes:
- ./config.ini:/app/config.ini
depends_on: depends_on:
- db - db
db: db:

24
main.py
View File

@@ -44,11 +44,15 @@ class Config:
self.createConfig(config) self.createConfig(config)
db = config['DB'] db = config['DB']
self.host = db['host'] self.host = db['host']
self.port = int(db['port']) self.port = int(db['port'])
self.dbname = db['name'] self.dbname = db['name']
app = config['App']
self.apphost = app['host']
self.appport = int(app['port'])
self.appdebug = bool(app['debug'])
def createConfig(self, config): def createConfig(self, config):
""" """
Create config file Create config file
@@ -59,6 +63,12 @@ class Config:
db['port'] = '27017' db['port'] = '27017'
db['name'] = 'pycms' db['name'] = 'pycms'
config['App'] = {}
app = config['App']
app['port'] = '8080'
app['debug'] = 'True'
app['host'] = '0.0.0.0'
with open('config.ini', 'w') as cfgfile: with open('config.ini', 'w') as cfgfile:
config.write(cfgfile) config.write(cfgfile)
@@ -104,6 +114,16 @@ class Back():
return bool(posts.delete_one({'name': name}).deleted_count) return bool(posts.delete_one({'name': name}).deleted_count)
class Metrics:
def alive():
return str("alive 1")
@route('/metrics')
def metrics():
return Metrics.alive()
@route('/post/<name>') @route('/post/<name>')
def post(name): def post(name):
''' '''
@@ -148,4 +168,4 @@ if __name__ == '__main__':
print("Configured") print("Configured")
back = Back() back = Back()
posts = cfg.posts posts = cfg.posts
run(host='0.0.0.0', port=8080, reloader=True, debug=True) run(host=cfg.apphost, port=cfg.appport, reloader=cfg.appdebug, debug=cfg.appdebug)

View File

@@ -8,3 +8,5 @@ $curl_cmd $url/post/test && echo ": get Success" || echo ': get fail'
$curl_cmd -X POST $url/admin/post/test -F 'body=testpage2' && echo ": Update success" || echo ': update fail' $curl_cmd -X POST $url/admin/post/test -F 'body=testpage2' && echo ": Update success" || echo ': update fail'
$curl_cmd -X DELETE $url/admin/post/test && echo ": delete success" || echo ': delete fail' $curl_cmd -X DELETE $url/admin/post/test && echo ": delete success" || echo ': delete fail'
$curl_cmd $url/metrics && echo ": metrics available" || echo ': metrics unavailable'