OpenWrt Forum Archive

Topic: can't change dirctory while using procd in openwrt

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

I have one service in /etc/init.d.it will be like this

#!/bin/sh /etc/rc.common
START=90
USE_PROCD=1
start_service() {
    cd /dir/
    procd_open_instance
    procd_set_param command usr/bin/Myservice
    procd_set_param respawn ${threshold:-20} ${timeout:-5} ${retry:-3}
    procd_close_instance
}

But while i am running this service it doesn't changing the directory to 'dir' thats why service doesn't started.For my service it is necessary to change the directory . So Please help with what i was missed .How to execute cd /dir/ command successfully.

It does not work because you are changing the current folder in the script that defines the service, not in the service itself. And I could not find any provision in procd to change the folder in the service. Perhaps you could create a small script that changes the fonder then calls the real service, and call that from the init.d script.

Hi eduperez,

                  Thank you for reply.if we are doing by a small script that changes directory and calling real service and calling that script in init.d script it was giving the fallowing info

Wed Mar 28 18:24:38 2018 daemon.info procd: Instance Myservice::instance1 s in a crash loop 4 crashes, 0 seconds since last crash


and it shows service was running but it's functionality not working properly

Perhaps the service binary is a daemon, is returning and remaining in memory, and the procd script detect that as an abnormal end.

But if trying to start the service in the fallowing manner it was working properly.But the problem is in this method i won't get the respawn action.for my service  it is necessary

#!/bin/sh /etc/rc.common
START=90

start() {
        logger -p user.notice "Myservice starting..."
        cd /dir/
        Myservice &
        logger -p user.notice "Myservice service started"
}

stop() {
        killall Myservice
        logger -p user.notice "Myservice service stopped"
}

Is there any way to provide respawn action for this.I tried with inittab respawn then Myservice was starting and it's gone killed automatically after some time then agian restarted this scenario was happening repeatedly . If any other way is there to do respawn please help me with that

Sorry, but I am not an expert in procd.

The discussion might have continued from here.