OpenWrt Forum Archive

Topic: Start a daemon after procd init complete

The content of this topic has been archived on 25 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi All,

We have added a script in /etc/init.d for starting our daemon
but we are unable to see the user level prints issued by the daemon.

So will starting a daemon after procd init completes help?
If yes, how can I do that

Please let me know your thoughts.

Thanks!
Vivek.

Is your problem with getting the daemon started or with getting log output from it?

Getting log output from it

You have not provided much context about the problem. You are sure that the daemon itself works otherwise ok and is running?

Does logging from that daemon work at all? Do you get log output if you manually start the daemon after the boot process has completed?

As far as I know, the output to stderr from a running program gets inserted into the log.

When I debugged a daemon a while ago, I inserted statements like
       fprintf(stderr, "log: connected to ubus\n");
and they materialized just fine to the system log.

(Last edited by hnyman on 8 Aug 2014, 08:12)

Hi hnyman,

Sorry for missing out on providing the details.
Yes the logging(printing on console) works after I start the daemon manually after boot.

I currently have the following lines in .etc/init.d/myinit

#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org

START=11

boot() {
        # commands to run on boot
        /bin/mydaemon &
}

However If I add a script  lib/preinit/99_20_myint
and start the /bin/mydaemon, I am able to see the prints in serial console.

Log daemon has START=12, so starting with a lower value may be problematic as logging is not available, yet.
(see http://git.openwrt.org/?p=openwrt.git;a … it;hb=HEAD )

The startup script looks a bit strange.

I would change the script to have a larger START value (like 19) and to use the normal start() instead of boot().

Then make sure that the script is executable and verify after running "/etc/init.d/myinit enable" that the symlink got properly created in /etc/rc.d/ as there should be S19MYINIT pointing to your actual script.

http://wiki.openwrt.org/doc/techref/initscripts


My guess is that you don't currently have the necessary symlink.

(Last edited by hnyman on 8 Aug 2014, 08:39)

Really appreciate your quick feedback.

I will update the script with the relevant changes as you mentioned and let you know.

Thanks!
Vivek

Hi vchettri,

                I am new to this topic.i want to create a customized daemon.But i didn't get the proper source for that.How to create a daemon using scripting.Please help me.

The discussion might have continued from here.