LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-11-2013, 11:57 AM   #1
stephaneeybert
Member
 
Registered: Feb 2005
Posts: 32

Rep: Reputation: 9
Debian insserv deamon starts but does not run my script


Hi,

I have root access on a Debian 7 server.

I have a deamon sitting in /etc/init.d/learnintouchsocket which I installed with the command: insserv learnintouchsocket

Here it is:
Code:
#!/bin/sh
#
# Learnintouch Socket server:   Start/stop the Learnintouch Socket server
#

### BEGIN INIT INFO
# Provides:          learnintouchsocket
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start learnintouchsocket at boot time
# Description:       Enable learnintouchsocket provided by daemon.
### END INIT INFO

case "$1" in
  start)
        /home/stephane/learnintouch/engine/js/socket/start.sh
        echo "Starting the socket server:"
        ;;
  stop)
        ;;
  *)
        echo "Usage: %s {start|stop}\n" "$0"
        exit 1
        ;;
esac

exit 0
Here is the content of the /home/stephane/learnintouch/engine/js/socket/start.sh file:
Code:
#!/bin/sh

echo 'In the start.sh file' >> /home/stephane/learnintouch/engine/js/socket/nodejs.log

nohup /home/stephane/programs/install/bin/node /home/stephane/learnintouch/engine/js/socket/elearning-server.js 2>&1 >> /home/stephane/learnintouch/engine/js/socket/nodejs.log &
After a server reboot I can see in the /home/stephane/learnintouch/engine/js/socket/nodejs.log file the following:
Quote:
In the start.sh file
But the log shows the following:
Quote:
In the start.sh file

module.js:340
throw err;
^
Error: Cannot find module 'utils.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/stephane/learnintouch/engine/js/socket/elearning-server.js:1:75)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
This tells me the custom node_module was not found.

Well, if I run manually, that is, by logging as root, and typing in the command: /etc/init.d/learnintouchsocket start
then the log shows:
Quote:
In the start.sh file
info: socket.io started
The NodeJS http server is listening...
To sum it up, the custom node_module is found when I run the init script manually as root, and it is not found when it is run as a deamon at reboot time.

Any clue ?

Kind Regards,

Stephane
 
Old 10-11-2013, 12:16 PM   #2
stephaneeybert
Member
 
Registered: Feb 2005
Posts: 32

Original Poster
Rep: Reputation: 9
I was missing the following in the /etc/init.d/learnintouchsocket file:

export NODE_PATH=/home/stephane/programs/install/lib/node_modules

I also had to specify the NodeJS to start AFTER the redis one with the following header:
# Required-Start: $remote_fs $syslog redis
in the /etc/init.d/learnintouchsocket file.

A server reboot now shows that the NodeJS server is correctly started:
In the start.sh file
info: socket.io started
The NodeJS http server is listening...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running script on bootup fails, "insserv myscript" ok pingu SUSE / openSUSE 5 05-22-2012 09:42 AM
[SOLVED] Script to run when terminal starts? dilzniksan Linux - General 1 06-02-2010 11:54 AM
[SOLVED] bash script (qmail) won't boot but starts from console (debian lenny) dbj Linux - Server 9 11-21-2009 07:03 AM
How to make a code to run as deamon?? makkays Programming 13 01-22-2007 06:59 AM
How to Write Script Program as Deamon bogoda Linux - Software 7 01-21-2006 12:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration