I am trying to write an init script for gitea in alpine. The first code I tried was


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.


1 Answer 1


This works (is the one shipped with gitea-openrc):


command_args="web --config '${GITEA_CONF:-/etc/gitea/app.ini}'"
supervise_daemon_args="--env GITEA_WORK_DIR='${GITEA_WORK_DIR:-/var/lib/gitea}' --chdir '${GITEA_WORK_DIR:-/var/lib/gitea}' --stdout '${GITEA_LOG_FILE:-/var/log/gitea/http.log}' --stderr '${GITEA_LOG_FILE:-/var/log/gitea/http.log}'"

depend() {
        use logger dns
        need net
        after firewall mysql postgresql

If you want to go ahead and use your script, please don't put the "&" at the end, and post the output of the logs.

.: Francesco

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .