3

I am trying to make rc-service start a Python script on startup (Alpine Linux). I have made a simplified example just to get things to work, but no luck.

I have added local to the default run-level, and I have two files in /etc/local.d/ - both owned by root:

one_api.start:

#!/sbin/openrc-run
command=one_api.py

one_api.py:

#!/usr/bin/python3

import uvicorn
from fastapi import FastAPI


app = FastAPI()


@app.get('/')
async def get_root():
    return {'message':'hello, world!'}


if __name__ == '__main__':
    uvicorn.run('one_api:app', host='127.0.0.1', port=8000, log_level='info')

When I try to start local I get * Starting local ... [!!]. I looked for a log in /var/log/ but rc-service doesn't write a log to that location, and I can't find it anywhere else. If I run the Python script manually it works fine.

Trying to start the service by itself also doesn't work:

$ sudo ./one_api.start start
 * Starting one_api.start ...
Segmentation fault
 * Failed to start one_api.start       [ !! ]
 * ERROR: one_api.start failed to start
henrikstroem
  • 2,978
  • 4
  • 35
  • 51
  • 1
    Hi, I tired this approch for python script, but not able to figure out. I will let you know if I can do anything, mean while I used supervisord to make script run on alpine docker here is link (https://stackoverflow.com/questions/49090469/docker-alpine-linux-running-2-programs) – DRPandya Sep 10 '20 at 08:20
  • @joker2368 I actually ended up using supervisord also, but I would like to avoid that. – henrikstroem Sep 10 '20 at 08:29

0 Answers0