#python

Python script to run multiple servers simultaneously on a local machine on Mac.

There are a number of times we have a bunch of servers we need to run to fully run an application, yes i am talking about the microservice arch. It's annoying to go to each repo and get the server running. Below is the script for making it automated.

#!/usr/bin/python3

"""
Script that starts the servers from the "services" array.
services = [
  {
    "name": "service_name",
    "path": "path_to_service",
    "command": "command_to_run",
  },
  ...
]
for a single server, please pass the name of the service to start...
author: msamgan
created at: 2022-05-01
updated at: 2022-07-22
version: 1.1.0
signature: ./server | ./server <service_name>
"""

import os
import sys

services = [
    
]

# uncomment if on mac os..
# os.system("say 'booting shopini servers'")
os.system("sleep 1")

n = len(sys.argv)

serverCommand = ""
for service in services:
    if n > 1:
        if service["name"] != sys.argv[1]:
            continue

    # say = "say 'booting " + service["name"] + " server'"
    # os.system(say)
    os.system(
        "ttab.sh -w -t '"
        + service["name"]
        + "' -d "
        + service["path"]
        + " "
        + service["command"]
    )

# os.system(
#     "say 'all shopini servers are running at there full potentials, have a nice day!'"
# )
# kill command: kill -9 $(lsof -ti:5100)

The ttab.sh library you will need

Most Viewed Posts


Must Read


January 28, 2022

#AppImage #linux

How to Add AppImage Application to Menu in Ubuntu (Linux)

AppImages are the most easiest to run compared.The challenging task is to make the AppImage accessible globally through he system like an installed application (in the menu)

Reading time: less than a minute
How to Add Laravel Pint to VS Code Formatter
June 24, 2022

#code-quality #vscode #laravel-pint #laravel

How to Add Laravel Pint to VS Code Formatter

I have been using the unsatisfactory formatters from a long time. All of them have one thing but lack other. Laravel Pint is one who has it all, combining it with vscode is like proving you laravel project a super power.

Reading time: 2 minutes
March 24, 2021

#express js #node #node js #sequelize #mysql

How to create model association in Sequelize - express JS / Node JS

In the very initial days of my work in Node JS if faced this issue. Though Sequelize provide a great ORM for MySQL but the association within the models is a bit tricky.

Reading time: 2 minutes
December 14, 2021

#database #javascript #sequelize #npx

Sequelize CLI Commands

list of Sequelize CLI commands which comes handy, while working on a project.

Reading time: 1 minute
How to create a progressive web app (PWA) in laravel 5.* and above
July 07, 2019

#functionality #pwa #javascript #laravel

How to create a progressive web app (PWA) in laravel 5.* and above

The progressive web app is the new trend as well as the need for the present time. I hope before getting in the “HOW” part you know what is exactly a PWA

Reading time: 4 minutes
mohammed-samgan-khan

Hi, I am Samgan, I know the adds are bit annoying but i hope you understand. Talking about me, I excel at solving complex problems involving logic and step by step breakdown of the problem. Besides, to develop complex algorithms, I specialize in problem framing, systems design, and product development strategy. Sometimes I also enjoy public speaking.