検索

文章
· 八月 7, 2024 阅读大约需 3 分钟

Exécution d'applications WSGI avec IPM

Introduction à l'exécution de WSGI dans IRIS

Avec IRIS 2024+, les utilisateurs peuvent héberger des applications WSGI à l'aide de Security.Applications. À titre d'exemple, un utilisateur peut faire quelque chose comme ceci.

Exemple minimal

zn "%SYS"
Kill props
Set props("Description") = "Sample WSGI Application"
Set props("MatchRoles") = ":%All"
Set props("WSGIAppLocation") = "/path/to/flaskapp"
Set props("WSGIAppName") = "myapp"
Set props("WSGICallable") = "app"
Set props("DispatchClass") = "%SYS.Python.WSGI" // important, sinon sera reconnu comme une application CSP
Set sc = ##class(Security.Applications).Create("/flask", .props)
zw sc

où le répertoire /path/to/flaskapp contient un fichier myapp.py

from flask import Flask

app = Flask(__name__)

@app.route("/")
def index():
    return "Hello, WSGI!"

Maintenant, accédez à l'URL http(s)://<host>:<port>/<optional-prefix>/flask/. Elle doit afficher « Hello, WSGI!» en texte brut.

Pièges courants

  1. Si l'URL http(s):///flask/ ne fonctionne pas, vérifiez d'abord la barre oblique finale, qui doit être présente.
  2. De plus, lors de la première exécution, flask doit être installé pour Embedded Python (pas votre interpréteur Python local au niveau du système d'exploitation). Vérifiez que l'installation a réussi en accédant au shell Embedded Python et en exécutant import flask.
  3. Enfin, l'autorisation de lecture de l'utilisateur du système d'exploitation qu'IRIS suppose doit être accordée à /path/to/flaskapp/myapp.py et à tous les dossiers parents.
  4. Si l'erreur ne peut toujours pas être résolue, vérifiez les entrées dans messages.log. Vous pouvez également nous contacter en publiant un problème

Utilisation d'IPM pour expédier des applications WSGI pour une installation facile

IPM facilite le processus en

  1. copiant le répertoire d'applications Flask vers un emplacement avec un accès en lecture garanti
  2. installant les dépendances Python pertinentes dans un fichier requirements.txt

Exemple de package

Voici un exemple qui peut être installé facilement partout où IPM (v0.7.2+) est installé sur IRIS 2024+. Clonez ce package dans un <PACKAGE_ROOT> approprié et démarrez un terminal IRIS

zn "%SYS"
zpm "load <PACKAGE_ROOT>"

Après une installation réussie, vous devriez pouvoir accéder à http(s)://<host>:<port>/<optional-instance-prefix>/my/flask/demo/. Dans mon cas, l'URL est http://localhost:8080/iris-ml-wsgi/my/flask/demo/ et elle contient :

This is a sample WSGI application using Flask!

Astuce : vous devez d'abord installer zpm en suivant les instructions ici pour que la commande zpm fonctionne.

Le module.xml du dépôt ci-dessus est également répertorié ici pour une référence rapide

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
  <Document name="flask-demo.ZPM">
    <Module>
      <Name>flask-demo</Name>
      <Version>1.0.0</Version>
      <Description>This is a demo of a flask application</Description>
      <Keywords>flask</Keywords>
      <Author>
        <Person>Shuheng Liu</Person>
        <Organization>InterSystems</Organization>
        <CopyrightDate>2024</CopyrightDate>
        <License>MIT</License>
        <Notes>notes</Notes>
      </Author>
      <Packaging>module</Packaging>
      <SystemRequirements Version=">=2024.1" />
      <SourcesRoot>src</SourcesRoot>
      <FileCopy Name="src/python/flaskapp/" Target="${libdir}flask-demo/flaskapp/"/>
      <SystemSetting Name="CSP.DefaultFileCharset" Value="UTF-8"/>

      <WSGIApplication
        Url="/my/flask/demo"
        UnauthenticatedEnabled="1"
        Description="Sample WSGI application using Flask"
        MatchRoles=":${dbrole}"
        WSGIAppLocation="${libdir}flask-demo/flaskapp/"
        WSGIAppName="app"
        WSGICallable="app"
       />
    <AfterInstallMessage>Module installed successfully!</AfterInstallMessage>     
    </Module>    
  </Document>
</Export>
讨论 (0)1
登录或注册以继续
文章
· 八月 6, 2024 阅读大约需 5 分钟

监控数据库增长 – 第 1 部分_数据收集

数据收集

这篇分步说明指南将讲解如何创建任务来收集 InterSystems 数据库及其全局变量的相关数据(如关联的 Open Exchange App 所示,其中包含所有相关代码)

免责声明:此软件仅用于测试/演示目的。 InterSystems 不支持将此代码作为任何发布产品的一部分。 它由 InterSystems 提供,作为特定产品和版本的演示/测试工具。 用户或客户全权负责此软件交付后的维护和测试,InterSystems 对此代码的错误或误用不承担任何责任

1) 首先,通过管理门户导入文件“DataCollection.xml”,并确保没有错误。 如果存在错误,则可能是版本问题,请发送电子邮件至 ari.glikman@intersystems.com 联系 Ari Glikman 获取适合你的版本的支持。 另外,确保将数据导入到你想要收集其内部数据以供后续检查的命名空间中。

3 Comments
讨论 (3)2
登录或注册以继续
文章
· 八月 6, 2024 阅读大约需 2 分钟

将Production中的设定参数移动到系统默认设置(System Default Settings)

开发新的互操作性Production时,最初在Production中添加设置是很自然的做法。

不过,一旦要将Production从开发环境移动到测试或其他环境,你就会发现 HTTP 服务器、IP 地址和/或端口之类的设置都需要更改。 为了避免这些设置在后续重新部署时被覆盖,必须将这些设置从Production得设置中移动到系统默认设置(System Default Settings)。

虽然系统默认设置可以手动创建,但是当生产中有大量业务组件时会难以处理。 因此,@Wietze Drost 让我开发一个工具自动执行此流程,通过筛选表达式指定哪些设置必须创建为系统默认设置。

  • 这个表达式可以定义为“*:HTTPServer,SSLConfig*”,其中“\*”表示“为任何主机类名”。 冒号后面是需要移动的设置列表。 所以,这个表达式的意思是“为所有名为 HTTPServer 和 SSLConfig 的设置创建或更新系统默认设置”。
  • 可以定义多个筛选表达式,用分号分隔,例如 "*:HTTPServer,SSLConfig;FullClassName2:xxx,yyy"

根据他的请求,我编写了名为 GetSettingsFromProduction 的类方法,

ClassMethod GetSettingsFromProduction(production As %String, filter As %String = "", removeFromProduction As %Boolean = 0, updateSettings As %Boolean = 1) As %Status

production - Production名称,如果留空,将使用当前正在运行的Production的名称。

filter - 用于选择设置的筛选器,如“*:HTTPServer,SSLConfig”。 可以添加多个筛选器,用“;”分隔,也可以使用特定类名。 如果筛选器留空,将处理所有设置。

removeFromProduction - 如果设为 1,将从Production中移除筛选器选择的设置。

updateSettings - 如果设为 0,将不会在系统默认设置中更新设置。

运行时,有关所采取操作的信息将被写入终端。 完整的类文件已粘贴在本文评论区。 欢迎提出问题和反馈!

1 Comment
讨论 (1)1
登录或注册以继续
文章
· 八月 6, 2024 阅读大约需 2 分钟

第二章 使用代理服务器

第二章 使用代理服务器

使用代理服务器

Web 客户端可以通过代理服务器与 Web 服务通信。要进行设置,请指定 Web 客户端实例的属性以指示要使用的代理服务器。这些属性如下:

HttpProxyServer

指定要使用的代理服务器的主机名。如果此属性不为空,则 HTTP 请求将定向到此计算机。

HttpProxyPort

指定代理服务器上要连接的端口。

HttpProxyHTTPS

如果使用代理服务器并且该代理服务器支持 HTTPS,则将其指定为 true

请注意,如果使用 HTTPS,则还必须将客户端的 SSLConfiguration 属性设置为 SSL/TLS 配置的名称;有关更多详细信息,请参阅配置客户端以使用 SSL

讨论 (0)1
登录或注册以继续
问题
· 八月 6, 2024

ERROR #6084: Unknown errors detected

Hi Guys,

I'm getting " ERROR #6084: Unknown errors detected" when compiling my CSP pages, the pages still works fine in the new 2018 system but can do any changes because of this error?

 

Thanks

讨论 (0)1
登录或注册以继续