I use FreeBSD UNIX and its rc system of startup scripts to make my Node.js servers start at reboot as a daemon and start, as a daemon again, and stop them with some commands the system gives me after I logged in to my FreeBSD UNIX user account.
I have read the Handbook related sections and an article on it, and I have written the following script, and the config, in /etc/rc.d/my_script and /etc.rc.conf, respectively. Which make it work as I described. When I add another script for another service only one of them work, I think usually the second one. Each server coded to listen to different port numbers.
my_script_1 is executable for all as '-rwxr-xr-x'.
/etc/rc.d/my_script_1:
#!/bin/sh
. /etc/rc.subr
name=my_service_1
rcvar=${name}_enable
project_dir="/usr/home/ec2-user/dev/projects/my_project_1"
command="/usr/local/bin/node"
command_args="${project_dir}/index.js"
load_rc_config $name
run_rc_command "$1"
/etc.rc.conf includes enabling var set:
my_service_1_enable="YES"
When I add another script and rc.conf entry like those with just name changed to a different name like, my_service_2, only one of them works. my_script_2 is executable as well.
What am I missing? How can I make them work both?