How to set automatic startup in freenas jails

How to set automatic startup in freenas jails

/etc/rc.d/syncthing

#!/bin/sh
. /etc/rc.subr
name="syncthing"
command="/usr/bin/syncthing"
pidfile="/var/run/${name}.pid"
load_rc_config $name
run_rc_command "$1"

service syncthing start

Starting syncthing.
[monitor] 10:37:41 INFO: Starting syncthing
[start] 10:37:41 INFO: syncthing v1.3.1-rc.2 "Fermium Flea" (go1.13.3 freebsd-amd64) teamcity@build.syncthing.net 2019-10-07 11:30:25 UTC
[start] 10:37:41 WARNING: Error opening database: resource temporarily unavailable (is another instance of Syncthing running?)
[monitor] 10:37:41 INFO: Syncthing exited: exit status 1
....
[monitor] 10:37:44 INFO: Starting syncthing
[start] 10:37:44 INFO: syncthing v1.3.1-rc.2 "Fermium Flea" (go1.13.3 freebsd-amd64) teamcity@build.syncthing.net 2019-10-07 11:30:25 UTC
[start] 10:37:44 WARNING: Error opening database: resource temporarily unavailable (is another instance of Syncthing running?)
[monitor] 10:37:44 INFO: Syncthing exited: exit status 1
[monitor] 10:37:45 WARNING: 4 restarts in 4.299149991s; not retrying further
/etc/rc.d/syncthing: WARNING: failed to start syncthing`Preformatted text`

It seems syncthing can’t open it’s database, potentially due to the jail being too restrictive, sadly I don’t think this is something we can help you with as it’s more of a jail question rather than a syncthing question.

Syncthing needs write access to the directory it keepa it’s database. Furthermor, it needs exclusive file access (via flocking) for the files in that directory.

Thank you very much for your reply.

/etc/rc.d/syncthing start

But when I run it manually with the above command, there is no problem.