Question

Run more programs in one component

Summarization I am using App Platform. I would like run more programs in one component. In my case its are:

  • Gunicorn (Flask App): gunicorn --worker-tmp-dir /dev/shm --config gunicorn_config.py app:app
  • Python (ZMQ server): python local_zmq_server.py

Both programs should be in operation throughout the running of the component.

What I tried I tried to follow documentation.

Both build and run commands can be compound (joined by && or separated by newlines) if you need to perform multiple actions at build or run time. App Platform will attempt to infer these commands at inspection time, however if it is unable to do so, you must set them manually.

It did not work. It just started only first command/program.

I also tried write some bash and python script which should pack both commands to one script. But It did not work again.

What I did wrong?

Thank you for any help


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

Could you share the bash script that you’ve used?

You could try using this one here from the official Docker documentation:

#!/bin/bash

# Start the first process
./my_first_process -D
status=$?
if [ $status -ne 0 ]; then
  echo "Failed to start my_first_process: $status"
  exit $status
fi

# Start the second process
./my_second_process -D
status=$?
if [ $status -ne 0 ]; then
  echo "Failed to start my_second_process: $status"
  exit $status
fi

# Naive check runs checks once a minute to see if either of the processes exited.
# This illustrates part of the heavy lifting you need to do if you want to run
# more than one service in a container. The container exits with an error
# if it detects that either of the processes has exited.
# Otherwise it loops forever, waking up every 60 seconds

while sleep 60; do
  ps aux |grep my_first_process |grep -q -v grep
  PROCESS_1_STATUS=$?
  ps aux |grep my_second_process |grep -q -v grep
  PROCESS_2_STATUS=$?
  # If the greps above find anything, they exit with 0 status
  # If they are not both 0, then something is wrong
  if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
    echo "One of the processes has already exited."
    exit 1
  fi
done

Regards, Bobby