如何在ubuntu 22.04中更改streamlit进程名称

xghobddn  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(86)

我的服务器上有两个streamlits应用程序正在运行,当应用程序部署在Ubuntu VM服务器上时,我们执行以下命令

$ nohup streamlit run dashboard1.py >data.out 2>&1 &
$ nohup streamlit run dashboard2.py >data.out 2>&1 &

字符串
它创造了这样的过程,

adminr@micro:~/$ ps -e | grep streamlit
132803 pts/0 00:00:10 streamlit
156959 pts/0 00:00:02 streamlit


我们可以将流程名称从streamlit更改为自定义名称,如“dashboard_销售”和“dashboard_college”。这将易于管理和重新部署。
请帮
我累了alreay python setproctitle包,但它不工作

import streamlit as st
import setproctitle # installed pip install setproctitle

# Set the process title
setproctitle.setproctitle("dashboard_sale")

# Streamlit app content
def main():
    st.title("Streamlit App with Process Title")

    st.write("This is a simple Streamlit app that sets the process title.")

if __name__ == "__main__":
    main()


运行此代码所需的包

pip install streamlit setproctitle

wfsdck30

wfsdck301#

这看起来像是一个重复的有没有办法在Python中更改有效的进程名称?。
简单地说:最简单的做法似乎是将所需的命令名写入/proc/self/comm.
请注意,此方法更改的是命令 name,而不是命令 line。任何报告命令行的内容都不会受到影响,这就是为什么“ps a”和“ps x”将显示可执行文件的名称,而不是您的自定义名称。

  • 更改将在“ps -e”中可见,您指示的是如何检查进程名称。
  • 该变化也将是可见的“pstree”
  • 如果使用“a”、“x”等标志,则更改对于“ps”将 * 不可见 *。

据我所知,如果您希望自定义名称作为命令行的一部分可见,则需要创建具有适当名称的可执行文件。
--klode

相关问题