Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
python_requires='>=3.10.4',
install_requires=[
'hio>=0.6.10',
'keri @ git+https://git@github.com/provenant-dev/keripy.git@v1.1.6-pr9',
'keri @ git+https://git@github.com/provenant-dev/keripy.git@VC-390',
'mnemonic>=0.21',
'multicommand>=1.0.0',
'falcon>=3.1.3',
Expand Down
4 changes: 2 additions & 2 deletions src/keria/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

from keria.app.cli.keria import main

if __name__ == "__main__":
main()

if __name__ == "__main__":
main.run()
43 changes: 42 additions & 1 deletion src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,36 @@
from ..core.keeping import RemoteManager
from ..db import basing

import cProfile
import pstats
import threading
import time

logger = ogler.getLogger()


def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=None, configDir=None,
def profile_app(interval=10, output_file=os.getenv("PROFILER_REPORT_FILE", "/home/origin/data/reports/profile.prof")):
profiler = cProfile.Profile()
profiler.enable()

def save_report():
while True:
print(f"Profiling report saved to {output_file}")
time.sleep(interval)
profiler.dump_stats(output_file)

# Start background thread to save profile periodically
threading.Thread(target=save_report, daemon=True).start()
return profiler

def setup(name, bran, adminPort, bootPort, credentialsPort, base='', httpPort=None, configFile=None, configDir=None,
keypath=None, certpath=None, cafilepath=None):

if os.getenv("PROFILING_ENABLED", "false").lower() in ("true", "1"):
print("Start profiling")
profiler = profile_app()
else:
print("Profiling disabled")
""" Set up an ahab in Signify mode """

agency = Agency(name=name, base=base, bran=bran, configFile=configFile, configDir=configDir)
Expand Down Expand Up @@ -118,6 +143,22 @@ def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=No
specEnd.addRoutes(happ)
happ.add_route("/spec.yaml", specEnd)

if os.getenv("SEPARATE_CREDENTIAL_CONTROLLER", "false").lower() in ("true", "1"):
print(f"Separate credential controller enabled on port {credentialsPort}")
# credentials
capp = falcon.App(middleware=falcon.CORSMiddleware(
allow_origins='*', allow_credentials='*',
expose_headers=['cesr-attachment', 'cesr-date', 'content-type', 'signature', 'signature-input',
'signify-resource', 'signify-timestamp']))
credentialing.loadCredentialsQuery(capp)
credentialsServer = createHttpServer(credentialsPort, capp, keypath, certpath, cafilepath)
credentialsDoer = http.ServerDoer(server=credentialsServer)
doers.append(credentialsDoer)
else:
print("Separate credential controller disabled")
credentialing.loadCredentialsQuery(app)


print("The Agency is loaded and waiting for requests...")
return doers

Expand Down
8 changes: 7 additions & 1 deletion src/keria/app/cli/commands/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
default=3903,
help="Boot port number the Boot HTTP server listens on. This port needs to be secured."
" Default is 3903.")
parser.add_argument('-C', '--credentials',
action='store',
default=3904,
help="Port for credentials operations. Default is 3904.")
parser.add_argument('-n', '--name',
action='store',
default="keria",
Expand Down Expand Up @@ -83,6 +87,7 @@ def launch(args):
admin=int(args.admin),
http=int(args.http),
boot=int(args.boot),
credentials=int(args.credentials),
configFile=args.configFile,
configDir=args.configDir,
keypath=args.keypath,
Expand All @@ -93,7 +98,7 @@ def launch(args):
".******", args.name, args.admin, args.http)


def runAgent(name="ahab", base="", bran="", admin=3901, http=3902, boot=3903, configFile=None,
def runAgent(name="ahab", base="", bran="", admin=3901, http=3902, boot=3903, credentials=3904, configFile=None,
configDir=None, keypath=None, certpath=None, cafilepath=None, expire=0.0):
"""
Setup and run a KERIA Agency
Expand All @@ -104,6 +109,7 @@ def runAgent(name="ahab", base="", bran="", admin=3901, http=3902, boot=3903, co
adminPort=admin,
httpPort=http,
bootPort=boot,
credentialsPort=credentials,
configFile=configFile,
configDir=configDir,
keypath=keypath,
Expand Down
2 changes: 1 addition & 1 deletion src/keria/app/credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def loadEnds(app, identifierResource):
credentialResourceDelEnd = CredentialResourceDeleteEnd(identifierResource)
app.add_route("/identifiers/{name}/credentials/{said}", credentialResourceDelEnd)

def loadCredentialsQuery(app):
queryCollectionEnd = CredentialQueryCollectionEnd()
app.add_route("/credentials/query", queryCollectionEnd)


class RegistryCollectionEnd:
"""
ReST API for admin of credential issuance and revocation registries
Expand Down