gusgard
gusgard

Reputation: 965

Deploy a TCP Server in Elastic-beantalk using python

I'm trying to deploy a tcp server written in python using ThreadedTCPServer.

Its possible to run this TCP server in beanstalk?

I don't want to use or change the WSGI server.

A temporal solution I have implemented is to create a image that have installed the tcp server and when it starts, it launches the server automatically. My beanstalk uses a custom ami to create new instances.

Yet, doing it this way, I can't use the benefits of beanstalk(log, git aws.push, etc)

Upvotes: 2

Views: 638

Answers (1)

Nate
Nate

Reputation: 3038

You could use a container_command to start your server process.

I've done this with some back-end processes that run alongside my WSGI server, but I don't see why you couldn't just do it without a WSGI server too.

Here's my .ebextensions/appname.config file:

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 &"

Each time you deploy with git aws.push it will kill the old process and start a new process from your new code.

Here's container_commands documentation: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands

Upvotes: 3

Related Questions