I've been trying to write an rc.d script for a site running with hugo, which is a static site generator that renders on-the-fly when changes are made.
I tried to build my script from this article, but when I set
The problem seems to be that
Here's my rc.d script:
I had it working with start_cmd (
Here's the output from uname -a:
FreeBSD VMS 11.0-RELEASE-p2 FreeBSD 11.0-RELEASE-p2 #0: Mon Oct 24 06:55:27 UTC 2016 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
Let me know if you need more information or things that I can try. Thanks so much!
I tried to build my script from this article, but when I set
${name}_chdir
(from rc.subr(8)), my service didn't work. I ran the script with #/bin/sh -x
, and this is the relevant output (I've removed parts specific to my situation):
Code:
+ _doit='cd /path/to/wd && /usr/local/bin/hugo <args...>'
+ [ -n '' ]
+ [ -n '' ]
+ [ -n '' ]
+ _doit='limits -C daemon cd /path/to/wd && /usr/local/bin/hugo <args...>'
+ _run_rc_doit 'limits -C daemon cd /path/to/wd && /usr/local/bin/hugo <args...>'
+ debug 'run_rc_command: doit: limits -C daemon cd /path/to/wd && /usr/local/bin/hugo <args...>'
+ eval 'limits -C daemon cd /path/to/wd && /usr/local/bin/hugo <args...>'
+ limits -C daemon cd /path/to/wd
+ /usr/local/bin/hugo <args...>
Error: Unable to locate Config file. Perhaps you need to create a new site.
Run `hugo help new` for details. (Config File "config" Not Found in "[/]")
daemon
is being run on cd
, not hugo
, but I don't know how to fix that or if I'm doing something wrong. I found this post on the mailing list that looks similar, but it's somewhat old, so if there was a bug, it's likely fixed.Here's my rc.d script:
Code:
#!/bin/sh -x
#
# $FreeBSD:
#
# PROVIDE: blog
# REQUIRE: LOGIN
# BEFORE: securelevel
# KEYWORD: shutdown
# Add the following line to /etc/rc.conf to enable `blog':
#
#blog_enable="YES"
#
. /etc/rc.subr
name="blog"
rcvar=`set_rcvar`
blog_chdir="/path/to/wd"
command="/usr/local/bin/hugo"
command_args="<args...>"
# read configuration and set defaults
load_rc_config "$name"
blog_enable=${blog_enable:-"NO"}
run_rc_command "$1"
I had it working with start_cmd (
start_cmd="cd /path/to/wd; /usr/sbin/daemon $command"
), but I'd prefer to learn how to do it the "right" way. Also, I plan on having several sites using hugo running from different directories, so I may need to do something more sophisticated to stop each one.Here's the output from uname -a:
FreeBSD VMS 11.0-RELEASE-p2 FreeBSD 11.0-RELEASE-p2 #0: Mon Oct 24 06:55:27 UTC 2016 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
Let me know if you need more information or things that I can try. Thanks so much!