init.d

How to start a Node.js app on system boot?

走远了吗. 提交于 2019-12-03 02:48:33
I'm working on a Raspberry Pi running Raspbian running a Node.js app and trying to get it to start when the Pi boots. I found a couple of examples but I can't seem to get it working. My current code is: #! /bin/sh # /etc/init.d/MyApp ### BEGIN INIT INFO # Provides: MyApp.js # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts MyApp.js # Description: Start / stop MyApp.js at boot / shutdown. ### END INIT INFO # If you want a command to always run, put it here # Carry out specific functions when asked

Call to daemon in a /etc/init.d script is blocking, not running in background

﹥>﹥吖頭↗ 提交于 2019-12-03 01:21:29
I have a Perl script that I want to daemonize. Basically this perl script will read a directory every 30 seconds, read the files that it finds and then process the data. To keep it simple here consider the following Perl script (called synpipe_server, there is a symbolic link of this script in /usr/sbin/ ) : #!/usr/bin/perl use strict; use warnings; my $continue = 1; $SIG{'TERM'} = sub { $continue = 0; print "Caught TERM signal\n"; }; $SIG{'INT'} = sub { $continue = 0; print "Caught INT signal\n"; }; my $i = 0; while ($continue) { #do stuff print "Hello, I am running " . ++$i . "\n"; sleep 3;

What is start-stop-daemon in linux scripting?

ぐ巨炮叔叔 提交于 2019-11-28 17:14:25
问题 What is start-stop-daemon and how should it be used? I am trying to automate a particular program to run. Whenever the system starts, the program should run. For that I am writing script in /etc/init.d/ location. 回答1: It is a program to manage the start and stop of system level background processes (daemons). You use it by passing in parameters (such as the pid file to create/check) and command arguments for the process you want to launch. Then, you do one of two things: start-stop-daemon -S

How can I log the stdout of a process started by start-stop-daemon?

落爺英雄遲暮 提交于 2019-11-28 02:48:07
I am using an init script to run a simple process, which is started with: start-stop-daemon --start --quiet --chuid $DAEMONUSER \ --make-pidfile --pidfile $PIDFILE --background \ --exec $DAEMON $DAEMON_ARGS The process called $DAEMON usually prints log information to its standard output. As far as I can tell this data is not being stored anywhere. I would like to write or append the stdout of $DAEMON to a file somewhere. The only solution I know is to tell start-stop-daemon to call a shellscript instead of $DAEMON directly; the script then calls $DAEMON and writes to the logfile. But that

Best practice to run Linux service as a different user

元气小坏坏 提交于 2019-11-27 09:59:20
Services default to starting as root at boot time on my RHEL box. If I recall correctly, the same is true for other Linux distros which use the init scripts in /etc/init.d . What do you think is the best way to instead have the processes run as a (static) user of my choosing? The only method I'd arrived at was to use something like: su my_user -c 'daemon my_cmd &>/dev/null &' But this seems a bit untidy... Is there some bit of magic tucked away that provides an easy mechanism to automatically start services as other, non-root users? EDIT: I should have said that the processes I'm starting in

Best practice to run Linux service as a different user

落花浮王杯 提交于 2019-11-27 04:09:45
问题 Services default to starting as root at boot time on my RHEL box. If I recall correctly, the same is true for other Linux distros which use the init scripts in /etc/init.d . What do you think is the best way to instead have the processes run as a (static) user of my choosing? The only method I'd arrived at was to use something like: su my_user -c 'daemon my_cmd &>/dev/null &' But this seems a bit untidy... Is there some bit of magic tucked away that provides an easy mechanism to automatically

How can I log the stdout of a process started by start-stop-daemon?

狂风中的少年 提交于 2019-11-26 23:49:29
问题 I am using an init script to run a simple process, which is started with: start-stop-daemon --start --quiet --chuid $DAEMONUSER \ --make-pidfile --pidfile $PIDFILE --background \ --exec $DAEMON $DAEMON_ARGS The process called $DAEMON usually prints log information to its standard output. As far as I can tell this data is not being stored anywhere. I would like to write or append the stdout of $DAEMON to a file somewhere. The only solution I know is to tell start-stop-daemon to call a

How to run a shell script at startup

▼魔方 西西 提交于 2019-11-25 23:42:35
问题 On an amazon linux instance, I have two scripts called start_my_app and stop_my_app which start and stop forever (which in turn runs my node.js app). I use these scripts to manually start and stop my node app. So far so good. My problem: I also want to set it up such that start_my_app is run whenever the system boots up. I know that I need to add a file inside init.d and I know how to symlink it to the proper directory within rc.d , but can\'t figure out what actually needs to go inside the