rcctl: How to debug in OpenBSD 6.4
Tags: openbsd, rcctl, debug, gitea
Published: 2018-11-23 14:03:45

---
title: rcctl: How to debug in OpenBSD 6.4
published: true
description: This post is about a single option around OpenBSD's rcctl, utility to "configure and control daemons and services". In a word, when running rcctl start %service% fails, using -d option provides a good information about why it fails.
tags: openbsd, rcctl, debug, gitea
cover_image: https://thepracticaldev.s3.amazonaws.com/i/71n3r8ztmwtpix67haik.jpg
canonical_url: https://obsd.solutions/en/blog/2018/11/23/rcctl-how-to-debug-on-openbsd-64/index.html
---

## Summary

This post is about a single option around [OpenBSD](https://www.openbsd.org/)'s [`rcctl`](https://man.openbsd.org/rcctl), utility to "configure and control daemons and services".

In a word, when running `rcctl start %service%` fails, **using `-d` option** provides good information about why it fails.

### Environment

- OS: OpenBSD 6.4 amd64

<center>✿ ✿ ✿</center>

## A Problem 

I tried to build a [Gitea](https://gitea.io/) server.
I was supposed to complete it with only 4 and a little more steps:

```shell-session
# pkg_add gitea
# rcctl enable gitea
# nvim /etc/gitea/conf/app.ini
# rcctl start gitea
```

But the reality bit:

```shell-session
# rcctl start gitea # the same to the last step in the above
gitea(failed)
```

I made desperate efforts to check logs and manuals like these:

```shell-session
# rcctl check gitea
$ nvim -R /var/www/logs/%some-log%
$ nvim -R /var/log/%some-log%
$ nvim -R /usr/local/share/doc/pkg-manuals/gitea
```

But the reality still tasted bitter 😖
There were too little information to find out the way.

## The Solution 

**`-d`** option is.

### Before

```shell-session
# rcctl restart gitea
```

The result is:

```shell-session
gitea(failed)
```

### After

```shell-session
# rcctl -d restart gitea
```

The result is:

```
doing _rc_parse_conf
doing _rc_quirks
gitea_flags empty, using default >web<
doing _rc_parse_conf /var/run/rc.d/gitea
doing _rc_quirks
doing _rc_parse_conf
doing _rc_quirks
gitea_flags empty, using default >web<
doing _rc_parse_conf /var/run/rc.d/gitea
doing _rc_quirks
doing rc_check
doing _rc_parse_conf
doing _rc_quirks
gitea_flags empty, using default >web<
doing _rc_parse_conf /var/run/rc.d/gitea
doing _rc_quirks
doing rc_check
gitea
doing rc_start
doing _rc_wait start
No home directory /nonexistent!
doing rc_check
Logging in with home = "/".
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=... addr=... pc=...]

goroutine 1 [running]:
code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).transformValue(...
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:123 +0x...
code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).String(...
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:130 +0x...
code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).MustString(...
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:202 +0x...
code.gitea.io/gitea/modules/setting.NewContext()
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/modules/setting/setting.go:1151 +0x...
code.gitea.io/gitea/routers.GlobalInit()
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/routers/init.go:47 +0x...
code.gitea.io/gitea/cmd.runWeb(...
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/cmd/web.go:83 +0x...
code.gitea.io/gitea/vendor/github.com/urfave/cli.HandleAction(...
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:471 +0x...
code.gitea.io/gitea/vendor/github.com/urfave/cli.Command.Run(...
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/command.go:191 +0x...
code.gitea.io/gitea/vendor/github.com/urfave/cli.(*App).Run(...
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:241 +0x...
main.main()
        /usr/obj/ports/gitea-1.5.0/go/src/code.gitea.io/gitea/main.go:52 +0x...
doing _rc_rm_runfile
(failed)
```

How rich the information is!
After all, thanks to Gitea's GitHub issues: [#4692](https://github.com/go-gitea/gitea/issues/4692) and [#4260](https://github.com/go-gitea/gitea/issues/4260) , I found it was caused by the wrong settings of `[U2F]` section in Gitea's `app.ini`.

```shell-session
# rcctl restart gitea
gitea(ok)
```

OK 😆

---

## Reference

`rcctl` has also a force option `-f` to start disabled service:

```shell-session
# rcctl -f start %disabled-service% 
%disabled-service%(ok)
```

<center>✿ ✿ ✿</center>

Happy serving 🕊