A daemon (background process) in python / VM/ Container / Docker Build for Deep Learning Model

Anudha Mittal
3 min readOct 29, 2024

https://web.archive.org/web/20131017130434/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

A daemon can be used to keep a connection open.

import socket

s = socket.socket()

host = ‘xx.xxx.xxx.xx’ # ip addr needs to be in quote

port = xxxx # an open port

s.connect((host, port))

print (s.recv(xxxx)) # a port number

inpt = raw_input(‘type anything and click enter… ‘)

s.send(inpt)

print( “the message has been sent”)

~

Combining different container builds. Dockerfile successfully built an image , size 1.41 GB, using this dockerfile.

Source for demucs part of the dockerfile https://github.com/xserrat/docker-facebook-demucs/blob/main/Dockerfile

The image size is larger than the RAM on nanonode on cloud services which has 1 GB ram. This VM was created with 3 GB RAM.

Would have to upgrade compute instance: https://www.linode.com/pricing/#compute-shared

Considering CI/CD, i.e. Continuous Development / Continuous Integration, development, when do we have to restart a virtual machine, a container, a container, or a daemon if there is a reconfiguration? For what types of reconfigurations do we have to restart, and what types of changes can be implemented without restarting?

In web applications: User input displays on an HTML page.

  1. The HTML page is generated by .py file that reads the user input from a database. — In this case the new user input is not immediately displayed, the .py file has to run again.
  2. HTML action can support rendering information without regeneration. Delineate the information flow for this.

E ncryption of Docker Files / Containers / Volumes

Transition from launching 50 containers to 5000 containers

Considerations:

  • Assigning port and ip addressses

Cron job vs. event handler. If the event frequency is unpredicatable, event handler (?).

Probing in

Check which python processes are running: ps aux | grep python

Which ports are running: netstat -tuln

which program is listening on a particular port, such as 3000

sudo lsof -i :3000

Probing in End

x — — — x — — — x — — — x — — — x

NGINX CONFIG FOR REVERSE PROXY TO WEBSOCKET SERVER

server {
listen 80;
server_name yourdomain.com;

location /ws/ {
proxy_pass
http://127.0.0.1:8000; # WebSocket server address
proxy_http_version 1.1; # Required for WebSocket support
proxy_set_header Upgrade $http_upgrade; # Support for WebSocket upgrade
proxy_set_header Connection “Upgrade”;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location / {
root /path/to/static/files;
index index.html;
}
}

Do pid’s, process id’s get re-assigned by OS for the same process if RAM is being competed for? How does OS manage pids. Can we refer to a process by $pid in a bash script?

# View the current maximum PID value

cat /proc/sys/kernel/pid_max

  • There are outdated dependencies in the installation. install with — no-dep. installed dependencies separately. One file, spawn.py, had an incompatible syntaxt when copy/pasting.
  • Spacy, mitie, total_word_feature_extractor.dat contribute to coherent, context accurate response.
  • DIET (dual intent and entity transformer) is an intermediary.
  • deadsnakes ~

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response