I am trying to write an init script for gitea in alpine. The first code I tried was
#!/sbin/openrc-run command=/usr/bin/gitea command_args="web" pidfile=/var/run/git.pid name="Gitea Daemon" description="Gitea - Git with a cup of tea" start() { ebegin "Starting Gitea" start-stop-daemon --start --exec /usr/bin/gitea \ --pidfile /var/run/git.pid eend $? } stop() { ebegin "Stopping Gitea" start-stop-daemon --stop --exec /usr/bin/gitea \ --pidfile /var/run/git.pid eend $? } Gitea does not fork, so when running above code, the service is starting and running but stays in foreground. So I tried to add --background option to start-stop-daemon. Now it is forking but the service is shown as „crashed“ although it’s running. I can fix this by manually creating a git.pid file, otherwise the service is unusable (won’t start nor stop) until I remove /var/run/openrc/started/git manually.
When using the code above and calling it in background by
rc-service git start & It will start gitea but rc-status shows the service as „starting“.
Additionally I did not accomplish to log the output. Maybe somebody can give me a hint on this. I tried to add a redirect to command_args but this did not work and a redirect of start-stop-daemon’s output is useless when run in background.