Missing "--pid-file path_to_pid_file" and "--daemon" options form my init service

just pointed that the options are missing, but how to replace it?

1 Like

You don’t use a startup script?

Just ran into this issue with my freebsd startup script…

I used it as startup via init.d services, but now the startup script doesn’t work as the part with PID a DAEMON doesn’t get any values anymore

I’m pretty sure you could adapt your SystemV script to not use daemon/pid, but it has been superseded by SystemD, anyway.

See below for a guide where you don’t need those parameters

lol, thanks, now it works, not sure why as there is no activation of python’s vEnv, but it works, thanks

For anyone looking for an updated SystemD script that doesnt use venv, here is the one I hacked together last night:

#!/bin/sh

# $FreeBSD$
#
# PROVIDE: hass
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# hass_enable (bool):      Set to NO by default.
#                          Set it to YES to enable home-assistant.
# hass_user (user):        Set to hass by default.
# hass_group (group):      Set to hass by default.
# hass_config_dir (path):  Set to /usr/local/etc/home-assistant/ by default.

. /etc/rc.subr

name=hass
rcvar=${name}_enable

command="/usr/sbin/daemon"

load_rc_config $name

: ${hass_enable:=NO}
: ${hass_user:=hass}
: ${hass_group:=hass}
: ${hass_config_dir:=/usr/local/etc/home-assistant/}

logfile="/var/log/${name}_daemon.log"
pidfile="/var/run/${name}_daemon.pid"

HA_CMD="/usr/local/bin/hass"
HA_ARGS="-v --ignore-os-check --config $hass_config_dir" 

start_precmd=${name}_prestart
start_postcmd=${name}_poststart
stop_postcmd=${name}_poststop
status_cmd=${name}_status 

hass_prestart() {
  install -g "${hass_group}" -m 664 -o ${hass_user} -- /dev/null "${logfile}"
  install -g "${hass_group}" -m 664 -o ${hass_user} -- /dev/null "${pidfile}"

  rc_flags="-f -o ${logfile} -P ${pidfile} ${HA_CMD} ${HA_ARGS}"
}

hass_poststart() {
	sleep 1 ; run_rc_command status
}

hass_poststop() {
  rm -f -- "${pidfile}"
}

hass_status() {
  if [ -n "${rc_pid}" ]; then
	echo "${name} is run as as pid ${rc_pid}."
  else
	echo "${name} is not running."
	return 1
  fi
}

run_rc_command "$1"