Modified rc.multi for starting daemons

I'd like to share some of my modification about the daemon starting process here
What I've done is to add an option for DAEMONS in rc.conf, which allows starting a daemon after all the previous dependencies are actually done.
This is done by a creating a named pipe for a before it starts, and removing it after the daemon completes.
Daemons with dependencies are guaranteed to either be blocked by reading the named pipe or fail to find the named pipe (which means it already completed) by some tricks.
Here is the snippet from the rc.multi:
depsd="/var/lock/boot"
mkdir -p "$depsd"
rm -f "$depsd"/*
start_daemon_dep(){
local dep daemon="$1"
shift
for dep; do
cat "$depsd/$dep" 2>/dev/null
done
start_daemon "$daemon"
/etc/rc.d/daemon_complete "$depsd/$daemon"
make_dep(){
mkfifo "$depsd/$1"
(cat "$depsd/$1") 2>/dev/null &
stat_bkgd "Starting daemon $1"
# Start daemons
for daemon in "${DAEMONS[@]}"; do
d=(${daemon//:/ })
case ${d[0]:0:1} in
'!') continue;;
make_dep "${d[0]#@}"
(start_daemon_dep ${d[0]#@} ${d[1]//,/ }) 1>/dev/null &
make_dep "${d[0]}"
start_daemon_dep ${d[0]} ${d[1]//,/ } 1>/dev/null
esac
done
/etc/rc.d/daemon_complete is the programing doing the atomic guarantee.
daemon_complete.c:
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv){
int fd;
if((fd = open(argv[1], O_WRONLY))< 0)
return 1;
if(unlink(argv[1]) < 0)
return 1;
if(close(fd) < 0)
return 1;
return 0;
Then we can write something like the following in rc.conf:
DAEMONS=(hwclock
rsyslogd
@network
@ntpdate:network
@dnsmasq:network
dbus
kdm:dbus,network
crond)
This means that ntpdate is running in background, but it won't start until its dependency, network, completes in background.
Multiple dependencies can be applied like the one kdm does: it relies on both dbus and network.
However, changing DAEMONS array syntax breaks some functionalities in /etc/rc.d/functions, so we have to accordingly change the file.
The file is here.
edit: I shouldn't put the executable in /etc/rc.d/functions.d/, so now it's in /etc/rc.d/
Last edited by realturner (2012-04-08 11:13:15)

I cannot contribute any specific thoughts yet,
but this is interesting.
I'll just post and follow this thread for the moment

Similar Messages

  • Is there a way to change the hotkey for starting firefox in safe-mode?

    The current default hotkey is shift. Holding it when starting firefox will start it in safe mode (true story). My super duper favorite handy windows hotkey for starting programs pinned to the task bar in windows 7 is windows_key + shift + #, and that conflicts with the firefox setting, and i always end up starting firefox in safe mode because im that lazy.

    Greetings!
    I'm an irssi user, and I have awesome mouse gesture addon for it, and I'm afraid I can't live without it anymore.. But it requires Shift key for opening links, therefore Firefox, as my default browser, always starts in Safe mode :(
    I'm not a programmer, easiest workaround would be modifying the irssi addon, but I suck on that, too.
    If there's a way to bypass Safe Mode in Firefox, or at least a way to change the Shift key to something else, that would make my miserable life a tad easier.

  • Using a LOV for the Start of a Tree - Pblms using LOV value for Start SQL

    I'm trying out my first APEX Tree using P20 and am having problems with it. The data structure is I have a clients table, an users table, a plans table and a union table (plan_users) that shows which users for a client are working on plans. An user belongs to a client and can be assigned to plans (plan_users).
    client_id (key to clients table and part of the composite key for users, plans and plan_users) is available as an application item which I can reference as :FOCUS_CLIENT_ID.
    I created several LOV's in the Shared Components. The PLANS_LOV returns all plans defined for the :FOCUS_CLIENT_ID. I've referenced this PLANS_LOV in the P20_ROOT_TREE which is setup to display the list of Plans for the Client as a SELECT LIST WITH SUBMIT. That seems to work and I can select the Plan.
    I then modified the SOURCE for the P20_ROOT_TREE to add a select statement to take the PLANS_ID selected in the LOV and use it in a Select to bring up the owner of the plan as the starting user for the tree. This is where I get an error when executing the SOURCE select statement which looks like this:
    select p.user_id id, p.plan_owner_id pid, u.user_lname name, null link
    from plan_users p, users u
    where p.client_id = :FOCUS_PLAN_ID and p.PLAN_ID = :PLANS_LOV
    and p.user_id = p.plan_owner_id
    and u.client_id = :FOCUS_PLAN_ID and u.user_id = p.user_id
    I'm guessing that the problem is what I'm referencing as :PLANS_LOV in the statement below. However I cannot find any information on how to reference the returned value from the PLANS_LOV for Page 20 so I've tried this.
    If this works right, then I want the user to select a PLAN from the LOV box and then see a tree displayed with all USERS hierarchically displayed beneath the Plan Owner. There may be multiple levels of users display under the Plan Owner.
    Here's the DEBUG page error I get. The number 4 is the correct Plan # I want to select Users for. The title on the page is "Available Plans". - Select Plan - is the default Null Value and Test Plan One is the Plan (#4) that I selected.
    Item: P20_TREE_ROOT COMBOBOX_WITH_SUBMIT
    Available Plans
    -Select Plan -Test Plan One
    [javascript:popupURL('f?p=4000:371:1020131294804981::::P371_ID,FB_FLOW_ID,FB_FLOW_PAGE_ID:1096326828951548,101,20');|Edit]Warning: Tree root ID "4" not found.
    0.05: Computation point: AFTER_BOX_BODY 0.05:
    Processing point: AFTER_BOX_BODY
    The query I'm using for populating the rest of the tree after the START is this statement below, but I don't think I'm getting to this point yet.
    select p.user_id id, p.plan_owner_id pid, u.user_lname name, null link, null a1, null a2
    from plan_users p, users u
    where p.client_id = :FOCUS_CLIENT_ID
    and u.client_id = :focus_client_id
    and u.user_id = p.client_id
    order by name
    I haven't been able to find any examples of someone using a LOV as part of the START definition for a Tree. All of the examples I've seen use a fixed value (i.e. 1).
    Anyone have some ideas?
    Thanks!
    Rob

    Hi,
    Try something like:
    select p.user_id id, p.plan_owner_id pid, u.user_lname name, null link, null a1, null a2
    from plan_users p, users u
    where p.client_id = :FOCUS_CLIENT_ID
    and u.client_id = :focus_client_id
    and u.user_id = p.client_id
    START WITH :FIRST_USER_ID
    CONNECT BY PRIOR p.user_id = p.plan_owner_id
    order by name:FIRST_USER_ID should be computed to be the first p.user_id value that matches the filter. Ideally, the p.plan_owner_id value should be null for this user as this user should identify the top of the tree. As an example, the following, using the EMP table, will allow you to display a tree with any manager as the root:
    SELECT
    EMPNO ID,
    ENAME NAME,
    CASE WHEN EMPNO = :P1_EMPNO THEN NULL ELSE MGR END PID,
    null LINK,
    null a1,
    null a2
    FROM EMP
    START WITH EMPNO = :P1_EMPNO
    CONNECT BY PRIOR EMPNO = MGRAndy

  • Start daemons with screen: rtorrent, irssi

    Hello, community!
    I run a headless server and, as of now, it boots with rtorrent as a daemon, using screen, like so:
    #!/bin/bash
    # file: /etc/rc.d/rtorrentd
    USER=myusername
    . /etc/rc.conf
    . /etc/rc.d/functions
    case "$1" in
    start)
    stat_busy "Starting rtorrent Service"
    su $USER -c 'screen -d -m -S rtorrent $USER' &> /dev/null
    if [ $? -gt 0 ]; then
    stat_fail
    else
    add_daemon rtorrentd
    stat_done
    fi
    stop)
    stat_busy "Stopping rtorrent Service"
    killall -w -s 2 /usr/bin/rtorrent &> /dev/null
    if [ $? -gt 0 ]; then
    stat_fail
    else
    rm_daemon rtorrentd
    stat_done
    fi
    restart)
    $0 stop
    sleep 3
    $0 start
    echo "usage: $0 {start|stop|restart}"
    esac
    exit 0
    The usual, as per our wiki and rtorrent documentation.
    I would like to do the same with irssi, but maybe I can't due to not completely understanding this statement:
    screen -d -m -S rtorrent $USER
    I know the "-d -m" part initializes screen and does not attach to it. "-S rtorrent" names that screen as "rtorrent" (I can check that doing
    C-a "
    when inside a screen)
    But that is as far as I know... I tried using the same script and replacing rtorrent -> irssi, but to no avail, it doesn't start by doing sudo /etc/rc.d/irssid start
    I don't need irssi to start at boot, but it would be nice just to
    sudo /etc/rc.d/irssid start
    and have my IRC setup ready. Any hints? Common mistakes?
    Thank you for your time
    edit: I also tried to follow irssi's guide but I can't create another screen session. (as in: only rtorrent has its own screen)
    Last edited by fhtagn (2011-01-26 05:25:57)

    Well, after messing with .screenrc I ended up doing it with a little help from the wiki.
    Now, my /etc/rc.d/irssi has:
    #!/bin/bash
    . /etc/rc.conf
    . /etc/rc.d/functions
    DAEMON=irssi
    USER=<username>
    PID=$(pidof -o %PPID $DAEMON)
    [ -r /etc/conf.d/irssi ] && . /etc/conf.d/irssi
    case "$1" in
    start)
    stat_busy "Starting $DAEMON Service"
    [ -z "$PID" ] && su $USER -c 'screen -dm -S '$DAEMON' -c ~/.irssi/.screenrc_irssi' &> /dev/null
    if [ $? != 0 ]; then
    stat_fail
    else
    add_daemon $DAEMON
    stat_done
    fi
    stop)
    stat_busy "Stopping $DAEMON Service"
    [ -n "$PID" ] && kill $PID &>/dev/null
    if [ $? != 0 ]; then
    stat_fail
    else
    rm_daemon $DAEMON
    stat_done
    fi
    restart)
    $0 stop
    sleep 3
    $0 start
    echo "usage: $0 {start|stop|restart}"
    esac
    exit 0
    and in ~/.irssi/.screenrc_irssi I have
    screen -t irssi irssi
    And it works!
    Is it overkill? Why do I need to have
    [ -z "$PID" ] && su $USER -c 'screen -dm -S '$DAEMON' -c ~/.irssi/.screenrc_irssi' &> /dev/null
    with '$DAEMON' instead of $DAEMON ? Otherwise it does not work... Probably something to do with bash

  • Advertise Bonjour for a daemon using launchd plist

    Gents,
    How do I use launchd.. plist to make bonjour available for my daemon?
    Its hard to find what is possible en what I need to setup in the plist.
    This sounds vague for me.
    Sockets <dictionary of dictionaries... OR dictionary of array of dictionaries...>
    This optional key is used .................... sed as inputs to call getaddrinfo(3).
    Bonjour <boolean or string or array of strings>
    This optional key can be used to request that the service be registered with the
    mDNSResponder(8). If the value is boolean, the service name is inferred from
    the SockServiceName. SockServiceName. Name.
    I would like, if it is possible to have, advertise Bonjour + Bonjour text available to the client.
    Also how will the total bonjour string looks like? Where can I find a description about that?
    Any references and idea's?
    Thank you.

    doug pennington wrote:
    I don't know the what of your text you want to advertise, but it, the text has to come off of your machines web server(at least from my experience). man dns-sd shows some info. The path can be tricky. Should be dns-sd -R "My Test" http.tcp . 80 path=/~short name/directory of text(with text enclosed)/ (I used Sites) Now this very possibly could not be what you are asking.
    I hope it is possible, because if a client.app is searching for the right service or kind of notification then is has to start the daemon before it get the text.
    I also have supply a service type, with that I have to add a TXT record with meta data.
    {quote}
    The specific nature of the TXT record and how it is to be used is service type dependent. Each service type will define zero or more name/value pairs used to store meta-data about each service.{quote}
    http://developer.apple.com/mac/library/qa/qa2001/qa1306.html
    and
    http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt Page 12 chapter 6...
    Also It looks like you now about this stuff I have another question, more developing specific.
    Hope to meat you there also http://discussions.apple.com/thread.jspa?threadID=2446760&stqc=true

  • Rc.d script in AUR for each daemon of interest?

    Hello everyone,
    first let me apologize if this has been asked before, but I couldn't find it with google and the forums search.
    What would you guys (especially the devs) think of creating an additional AUR package for every daemon of interest with an -rcd suffix, that just contains an rc.d script?
    For example:
    cups -> cups-rcd
    openssh -> openssh-rcd
    These could then pull the regular package, so users who prefer the rc.d scripts may use the following command to get the official package and also get rc.d scripts:
    $favoriteAurHelper -S cups-rcd openssh-rcd
    Positive notes:
    - We could use the already existing AUR infrastructure with all its nice features: everyone could submit an rc.d script for their favorite daemon(s), post comments with improvements/suggestions/..,
    - We could use the existing AUR tools to install those packages
    - It would not be necessary to repackage every daemon
    Negative:
    - The AUR would get a lot of new packages all over sudden
    - Arch dev team might not like it (which is totally fine for me)
    - No pure systemd-free Arch Linux system (but who has the time for that anyway?)
    I am not saying that I have the time to get at least one box running without systemd and actually use those rc.d scripts, it's just a question that I have on my mind. And even if no one likes the idea, at least there would be a thread about it and others could read up on it.
    Please do not abuse this thread to share your opinion on init systems and why any of them should be better than the others, do this on your personal blog.
    Last edited by robotanarchy (2013-05-20 23:33:17)

    Trilby wrote:There is no need for dev approval, and asking them to do it is ... I can't find just the right word for this sentence, I don't think it's *bad* per-se, but odd.
    Well I thought it was a good idea to ask/discuss it, because it wouldn't be just a few packages and systemd alternatives seem to be sort of a sensitive topic currently.
    karol wrote:Why not create one package with all the daemons?
    graysky wrote:Why not start a collection of scripts in github like falconindy did for systemd way back when?  One package, many scripts, easy.
    It's easier to keep track of the changes (actually read the new rc.d scripts) and maybe easier to maintain. You could also downgrade/change single rc.d scripts in case one is broken rather than downgrading them all.
    Last edited by robotanarchy (2013-05-21 00:12:34)

  • Conditions for starting WF - BO BOR Purchase contract

    Hi all,
    we have SRM application rel. 5.0 (Server 5.5) and our need is to deactivate contract's approvement, about a contract just approved, whe user modify some fields in header or item data on contract.
    Under dir SPRO --> SRM --> SRM Server --> Cross-application basic settings --> SAP business workflow --> Define conditions for starting workflows i have selected following values: "BOR" - "Purchase contract" and event "CHANGEVERSIONSAVED" and i tried to managed Start routine n° WS14000086 e WS14000088 with expression "Changed fields" using field CRMD_ORDERADM_H-DESCRIPTION, for example, but in this way i only got issue that approvement flow doesn't go !!!!
    Did i follow right way ? miss i something ?
    May you help me ?
    Best regards,
    Nick.

    Hi,
    It is either possible to use workflow (or) not to use workflow.
    It is not possible to deactivate workflow in the middle of the approval process. for example if the approver changes the contract and approves, then the contract will be approved if it is single step approval.
    if the approver changes the contract and then approves , then it will be send either to the next approver (or) creator depending on workflow security leve.
    But i am sorry it is not possible to deactivate workflow in the middle of workflow process.

  • Safari seems not sending If-Modified-Since header for main address

    Not sure I'm in the appropriate forum but let's try (if there is more appropriate one please advise).
    When Safari requests a resource (page, image...) to a web server it doesn't provide If-Modified-Since header for the main resource of the request. That means the web server can't answer "resource not modified, use your cache". This is not the behavior of other browsers and not good in terms of performance for the web server as well as for the user.
    However Safari sends this If-Modified-Since for the sub-elements of the resource (e.g. images, css in a page...). Which is good.
    Is there a way to influence Safari's behavior to provide a If-Modified-Since for the main resource requested to the server?
    acama,

    Found out the answer.  IIS 6 does in fact steal "If-Modified-Since" and "If-None-Match" headers, but only on custom 404 redirects.  That's actually what I'm doing here (that'll teach me not to put details in a question when I think they're irrelevant -- actually I just forgot).
    Here's two discussions on the issue (they're using ASP, but apparently it's the same for ColdFusion):
    http://www.eggheadcafe.com/conversation.aspx?messageid=32839787&threadid=32839787
    http://www.webmasterworld.com/microsoft_asp_net/3935439.htm

  • How to create business operation for starting workflows

    How to create business operation for starting workflows from worklist?
    When I call methods that implements business operation from java class everything
    works fine(wlpi-ejb.jar is required), but when I call business operation from
    Studio I can't use classes from wlpi-ejb.jar.

    Business operation is called by WLIS. So, I include wlpi-ejb.jar into WLIS classpath.
    Studio uses deployed EJB from wlpi-*.jar, I don't know why Studio doesn't see
    methods from deployed EJBs when WLIS classpath contains wlpi-ejb.jar.
    "Andrew Pitonyak" <[email protected]> wrote:
    >
    When studio starts, what is your classpath? If you use the included batch
    file to start it, then your class path may not include this :-)
    Andrew
    "Raul" <[email protected]> wrote in message
    news:[email protected]..
    How to create business operation for starting workflows from worklist?
    When I call methods that implements business operation from java classeverything
    works fine(wlpi-ejb.jar is required), but when I call business operationfrom
    Studio I can't use classes from wlpi-ejb.jar.

  • HTTP handler for starting an external service cannot be read

    Hi,
    When i execute the work item from Business Work place and also from the UWL in Enterprise portal of the task TS21300098 for HR Process Requisition workflow.
    In the Error is says
    HTTP handler for starting an external service cannot be read
    Message no. SWK045
    Diagnosis
    This work item is a link to a HTTP service. To start the service, a launch handler must be known to the SAP System.
    However, the system could not find a launch handler.
    System Response
    The workflow system cannot start execution of the work item.
    Procedure
    Contact your workflow administrator:
    In Customizing you must maintain a launch handler for HTTP-supported dialog services.
    I have checked the config under WF_HANDCUST transaction and made the launch Handler settings generated automatically.
    But still the problem occurs.
    Any Suggesions and help?
    Thanks & Regards
    Sumanth

    hi Guys,
    I have got the same issue. This blog helped me with tcode WF_HANDCUST. I have generated the url
    http://waspgh.kcc.com:8083/sap/bc/webflow/wshandler-->Click on Generate URL and click on distribution.
    Immediately u will get click on Test url . Click Test url . Then It is not successful. It stopped at 
    http://waspgh.kcc.com:8083/sap/bc/webflow
    Getting http page error. So use tcode sicf >sap>bc-->webflow service and activate it.
    Then test the connection. It will be successfull.
    http://waspgh.kcc.com:8083/sap/bc/webflow/wshandler?ping=true&sap-client=400
    Handler test
    Test successful
    Thanks,
    Shankar

  • Outlook 2013 window missing Last Modified By information for Sharepoint 2010 calendar appointment

    We have been running Sharepoint 2010 for about a year now, along with Office 2010. We have recently begun testing the upgrade to Office 2013. What we've found is that when in Outlook 2013 viewing a synced Sharepoint 2010 calendar appointment, you no longer
    see the Last Modified By information at the bottom right-hand corner of the window. If you try viewing a shared Exchange calendar's appointment that is not on Sharepoint, you do see this information.
    Can anyone else confirm this, and suggest whether anything can be done to restore the functionality?

    Hi,
    According to your post, my understanding is that you can’t see the “Last modified by” information at the bottom right-hand corner of the window when you view a synced SharePoint 2010 calendar appointment in Outlook 2013.
    In my environment, I create a calendar event in Outlook 2013, and the result is that I can’t see the “Last modified by” information at the bottom right-hand corner of the event window when I click on this event.
    It’s by design that it will not show the “Last modified by” information at the bottom right-hand corner of the event window when we click on this event in Outlook 2013.
    As a workaround, I recommend that you can follow the steps as below to change the current view to list view and show the information.
      1.  Open your calendar in Outlook 2013, go to “View“ tab, click on “Change View”, select the “Manage Views”.
      2.  Select the “List” view, click on the “Modify”, click on the “Columns”, select available columns from: All Mail fields, select the “Changed by” to add and move it up.
      3.  Go back to the “Change view”, select the “List” view and it will show all the calendar events with the “Changed by” information in a list.
    And, if you want to set other settings of the current “List” view, you can click on the “View Settings” to modify it.
    For more information, you can refer to:
    https://support.office.com/en-us/article/Create-change-or-customize-a-view-f693f3d9-0037-4fa0-9376-3a57b6337b71
    Best Regards,
    Yumi Fu

  • Using DAQ occurrence to wait for start trigger

    Hi,
    I'm trying to use digital triggers to start and stop datalogging. Every time start trigger appears, new file is created and data is acquired to file until stop trigger occurs. Now I'm using set DAQ occurrence and wait for occurrence functions to wait for start trigger before creating a new file. The problem is that after first stop trigger this occurrence method doesn't work. I believe it's because AI is not cleared and configured before calling DAQ occurrence again. Number of scans acquired is not zero, if I don't clear and configure AI again? Am I right?
    Do I have to clear and init AI everytime before occurrence config or is there a better way to make program wait for start trigger?
    Thanks in advance,
    Jakke

    Hi Matt99eo,
    Have you configured your device for triggering?  Although you have not mentioned your device specifically, the M series user manual provides a great explanation of digital triggering.  Using the DAQ Assistant, this can be configured from the triggering tab.  Hopefully this helps!
    Regards,
    h_baker
    National Instruments
    Applications Engineer
    Digital Multimeter Resources

  • XSL for starter

    I am new to XML/XSL world. Finding it really difficult to XSL processes the XML tree. I am getting unexpected nodes to be selected using XPATH expressions. Can any one suggest any good books on XSL for starter or any web site for learing XSL. Any other tips will be great
    Thanks,
    Sunil

    Take a look at:
    http://www.ibiblio.org/xml/books/bible2/
    http://www.zvon.org/xxl/XSLTutorial/Books/Book1/index.html
    Good luck.

  • What is prereq for reading above, and for start develop/reading with flex and cf(level?) ?

    http://www.adobe.com/devnet/flex/pdfs/getting_started_with_Flex3.pdf
    what is prereq for reading above, and for start develop/reading with flex and cf(level?) ?

    The Flex Quickstarts will be a place for starters, if you want to know 
    about Flex/CF integration the first to know would be some basics of CF.
    Sincerely,
    Michael
    Sent from my iPhone

  • Help: how to modify a setting for a running

    solaris 10 10/05 on sUN E3000
    Q: how to modify the setting for a running zone.
    I want to add a lofs mount for /usr/local read/write.
    also I want to add access to cdrom
    so I use zonecfg to "add fs ", and stuff then commit.
    now what should I do to make effect in the zone.
    thanks.

    to rephase my question:
    once I have a zone installed, is there a way to
    modify the zone settings , such as adding a fs
    or devices, without destory the zone? thanks.

Maybe you are looking for