WIP add apache wsgi configuration
This commit is contained in:
parent
27b342623a
commit
e6ab985c12
5 changed files with 26 additions and 7 deletions
|
@ -11,11 +11,11 @@ pip install -r requirements.txt
|
||||||
### rpm
|
### rpm
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dnf install python3-flask
|
dnf install python3-flask python3-mod_wsgi
|
||||||
```
|
```
|
||||||
|
|
||||||
## run
|
## run
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
python3 koji-forgejo-webook.py
|
python3 koji-forgejo-webook.py
|
||||||
```
|
```
|
||||||
|
|
5
config.ini
Normal file
5
config.ini
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[DEFAULT]
|
||||||
|
SECRET_KEY = $3cr3tk3y
|
||||||
|
KOJI_SERVER = https://kojidev.stackwebservices.org/kojihub
|
||||||
|
KOJI_TARGET = rl9-candidate
|
||||||
|
WEBHOOK_SECRET_KEY = your_secret_key
|
5
koji_forgejo_webhook.conf
Normal file
5
koji_forgejo_webhook.conf
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
WSGIDaemonProcess forgejo processes=2 threads=4
|
||||||
|
WSGIScriptAlias /forgejo-webhook /opt/koji-forgejo-webhook/koji_forgejo_webhook.wsgi
|
||||||
|
<Directory /opt/koji-forgejo-webhook>
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
|
@ -2,17 +2,17 @@ import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import logging
|
import logging
|
||||||
|
import configparser
|
||||||
from flask import Flask, request, abort
|
from flask import Flask, request, abort
|
||||||
import koji
|
import koji
|
||||||
|
|
||||||
|
# Load configuration from .ini file
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read('config.ini')
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config['SECRET_KEY'] = '123'
|
app.config.from_mapping(config['DEFAULT'])
|
||||||
# koji
|
|
||||||
app.config['KOJI_SERVER'] = 'https://kojidev.stackwebservices.org/kojihub'
|
|
||||||
app.config['KOJI_TARGET'] = 'rl9-candidate'
|
|
||||||
|
|
||||||
app.config['WEBHOOK_SECRET_KEY'] = 'your_secret_key'
|
|
||||||
|
|
||||||
class KojiProcessor:
|
class KojiProcessor:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -98,6 +98,7 @@ class ForgejoWebhookProcessor:
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/', methods=['POST'])
|
||||||
@app.route('/forgejo-webhook', methods=['POST'])
|
@app.route('/forgejo-webhook', methods=['POST'])
|
||||||
def webhook():
|
def webhook():
|
||||||
processor = ForgejoWebhookProcessor(app.config['WEBHOOK_SECRET_KEY'])
|
processor = ForgejoWebhookProcessor(app.config['WEBHOOK_SECRET_KEY'])
|
||||||
|
@ -115,6 +116,7 @@ def webhook():
|
||||||
|
|
||||||
return 'Webhook processed', 200
|
return 'Webhook processed', 200
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
app.run(host="0.0.0.0", port=5001)
|
app.run(host="0.0.0.0", port=5001)
|
7
koji_forgejo_webhook.wsgi
Normal file
7
koji_forgejo_webhook.wsgi
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(stream=sys.stderr)
|
||||||
|
sys.path.insert(0, "/opt/koji-forgejo-webhook")
|
||||||
|
|
||||||
|
from koji_forgejo_webhook import app as application
|
Loading…
Add table
Reference in a new issue