kezhenxu94 commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-895229962
> I'm quite interested in this one, could you elaborate a bit more on how
this can be achieved? @kezhenxu94
@Superskyyy thanks for your interest, the basic idea is to write a command
line tool (in Python language, for example, named `sw-python`) and start the
SkyWalking Python agent first, then start the user-app command, e.g. `sw-python
app.py`, or `sw-python gunicorn myproject.wsgi`, or `sw-python django ......`,
etc.
I haven't had a chance to look into the details but the following might be a
start point:
```python
import os
import sys
from skywalking import config, agent
if __name__ == '__main__':
args = sys.argv[1:]
bin_directory = os.path.dirname(sys.argv[0])
python_exe = os.path.basename(sys.executable)
python_exe_path = os.path.join(bin_directory, python_exe)
if (not os.path.exists(python_exe_path) or
not os.access(python_exe_path, os.X_OK)):
python_exe_path = sys.executable
config.service_name = 'provider'
config.logging_level = 'DEBUG'
agent.start()
os.execl(python_exe_path, python_exe_path, *args)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]