|
| 1 | +### PythonMS-CLI |
| 2 | + |
| 3 | +Python MicroService is a Python utility to manage your Python scripts. |
| 4 | + |
| 5 | +You can remotely check if they are up and running, their state, automatically restart them in case of failure and log and kill, stop or restart them. |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +- Python3.4 |
| 10 | +- Pip (recommended) |
| 11 | + |
| 12 | +## Setup |
| 13 | + |
| 14 | +Install the required python modules |
| 15 | + |
| 16 | +``` pip install -r requirements.txt ``` |
| 17 | + |
| 18 | +You can install PythonMS as a service as root using the pythonms.service (systemd compatible) |
| 19 | + |
| 20 | +``` ln -s $PWD/pythonms.service /etc/systemd/system/ ``` |
| 21 | + |
| 22 | +## Configuration |
| 23 | + |
| 24 | +Before starting to use PythonMS you must configure it. You can use the config.example.py for reference : |
| 25 | + |
| 26 | +``` |
| 27 | +run={ |
| 28 | +"SMTPTester" : {"directory":"SMTPTester", "restart":False, "main_method":"main", "repository":"https://github.com/lup\ |
| 29 | +in012345/SMTPTester.git"}, |
| 30 | + "epitech_api_flask" : {"repository":"https://github.com/lupin012345/epitech-api-public.git", "restart": False, "main_\ |
| 31 | +method":"app.run", "directory":"epitechApi", "flask":{"host":"0.0.0.0", "port":8081}}, |
| 32 | +"myScript" : {"directory":"myscript_dir", "restart":True, "main_method":"run"} |
| 33 | +} |
| 34 | +
|
| 35 | +daemon={ |
| 36 | + "port": 4242, |
| 37 | + "host": "127.0.0.1", |
| 38 | + "services_directory": "run", |
| 39 | + "password": "password", |
| 40 | + "log_file": "/var/log/pythonms.log" |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +### Usage |
| 45 | + |
| 46 | +Once you run PythonMS with the ```pythonms``` Python script, it listens on the selected port. |
| 47 | + |
| 48 | +I'm not sure there exactly a need for a PythonMS client since the Netcat package can do everything I'd like a client to do. |
| 49 | + |
| 50 | +That's why I recommend to use telnet or netcat to interact with your PythonMS server, for instance : |
| 51 | + |
| 52 | +```nc your_host your_port``` |
| 53 | + |
| 54 | +You will then be prompted for your password, enter it |
| 55 | + |
| 56 | +``` |
| 57 | +### Python Manager |
| 58 | +Hello ! |
| 59 | +(password) |
| 60 | +#> your_password |
| 61 | +``` |
| 62 | + |
| 63 | +You can now use the following commands in the prompt : |
| 64 | + |
| 65 | +- quit : Kill the running daemon and server |
| 66 | +- list : List the services you added to the server |
| 67 | +- start {id}: Start one of your services |
| 68 | +- kill {id}: Kill one of your services |
| 69 | +- status {id}: Show informations about one of your services |
| 70 | +- restart : Restart the daemon and server. To refresh your configuration for example |
| 71 | +- clear : Clear the screen |
| 72 | +- keepalive {id} {True|False} : Choose if a service should be automatically restarted or not |
| 73 | +- log : Print the contents of the logfile |
0 commit comments