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?
daemonutility an option here? – sçuçu Oct 22 '18 at 19:40pkg, and have successfully invokeddaemon node project1/index.jsanddaemon node project2/index.js. Althoughpsdoes not show them running,sockstatoutputs the port 3000 and 4000, ports theproject1andproject2coded to use, as being used by a command named node. But do not know how to reach them from my host mac (don't know the ip of my virtual machine freebsd). I trieddaemonsince I cannot run two node commands to test what you said without closing one first since it is attached to stdout. – sçuçu Oct 22 '18 at 19:48sshinto my virtual machine freebsd from its host mac. 3. (similar to 2.) sending http requests to a server on my virtual machine freebsd from its host mac, e.g. from a browser. – sçuçu Oct 22 '18 at 19:52daemonwill enhance the scope and then make it harder for you to debug. You are on the right path by ssh'ing into the VM and browse from your host.You have a lot of lessons to learn - but keep up the work! – Claus Andersen Oct 23 '18 at 07:36curlfrom packages, via pkg, on virtual os and I have seen the successful response from on virtual os by invoking it with reapective http urls of my projects. – sçuçu Oct 23 '18 at 07:56