使用python在Elasticbeantalk中部署TCP服务器

2024-10-03 21:27:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图使用ThreadedTCPServer部署用python编写的tcp服务器。在

是否可以在beanstalk中运行此TCP服务器?

我不想使用或更改WSGI服务器。在

我实现的一个临时解决方案是创建一个安装了tcp服务器的映像,当它启动时,它会自动启动服务器。我的beanstalk使用自定义的ami来创建新实例。在

但是,这样做,我不能使用beanstalk(log,gitaws.push等)的好处


Tags: 实例服务器logwsgi部署解决方案pushtcp
1条回答
网友
1楼 · 发布于 2024-10-03 21:27:31

您可以使用container_command来启动服务器进程。在

我已经在我的WSGI服务器旁边运行了一些后端进程,但是我不明白为什么没有WSGI服务器就不能这样做。在

这是我的电子分机/应用程序名.config文件:

container_commands:
  01_kill_old_server:
    command: "pid=`ps -aefw | grep 'myserver.py' | grep -v ' grep ' | awk '{print $2}'`; kill -9 $pid > /dev/null 2>&1 "
    ignoreErrors: true
  02_start_server:
    command: "nohup python ./myserver.py > foo.out 2> foo.err < /dev/null &"

每次使用git aws.push进行部署时,它都会终止旧进程并从新代码启动新进程。在

以下是container_commands文档:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands

相关问题 更多 >