WIP add apache wsgi configuration
This commit is contained in:
parent
27b342623a
commit
e6ab985c12
5 changed files with 26 additions and 7 deletions
|
@ -11,7 +11,7 @@ pip install -r requirements.txt
|
|||
### rpm
|
||||
|
||||
```shell
|
||||
dnf install python3-flask
|
||||
dnf install python3-flask python3-mod_wsgi
|
||||
```
|
||||
|
||||
## run
|
||||
|
|
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 hmac
|
||||
import logging
|
||||
import configparser
|
||||
from flask import Flask, request, abort
|
||||
import koji
|
||||
|
||||
# Load configuration from .ini file
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['SECRET_KEY'] = '123'
|
||||
# koji
|
||||
app.config['KOJI_SERVER'] = 'https://kojidev.stackwebservices.org/kojihub'
|
||||
app.config['KOJI_TARGET'] = 'rl9-candidate'
|
||||
app.config.from_mapping(config['DEFAULT'])
|
||||
|
||||
app.config['WEBHOOK_SECRET_KEY'] = 'your_secret_key'
|
||||
|
||||
class KojiProcessor:
|
||||
def __init__(self):
|
||||
|
@ -98,6 +98,7 @@ class ForgejoWebhookProcessor:
|
|||
abort(400)
|
||||
|
||||
|
||||
@app.route('/', methods=['POST'])
|
||||
@app.route('/forgejo-webhook', methods=['POST'])
|
||||
def webhook():
|
||||
processor = ForgejoWebhookProcessor(app.config['WEBHOOK_SECRET_KEY'])
|
||||
|
@ -115,6 +116,7 @@ def webhook():
|
|||
|
||||
return 'Webhook processed', 200
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
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