Method code for $sys.startup()

[Turn on line numbering]
arg args;
var opt, str, obj, f, ver, firsttime, doinit;

set_heartbeat(0);

// clean db?
if ("-clean" in args) {
    catch any {
        dblog("** Cleaning Database..");
        (> .clean_database() <);
        dblog("** Done.");
        if (dict_contains(startup, 'time))
            startup = dict_del(startup, 'time);
    } with {
        .log($parse_lib.traceback(traceback()));
    }
    doinit = "-init" in args;
} else {
    doinit = "-init" in args || !dict_contains(startup, 'time);
}

// init?
if (doinit) {
    catch any {
        dblog("** Initializing Database..");
        (> .init_database() <);
        dblog("** Done.");
    } with {
        .log($parse_lib.traceback(traceback()));
    }
}

// done?
if ("-quit" in args) {
    dblog("** Shutting down.");
    .shutdown();
    return;
}

// make core?
if ((opt = find opt in (args) where (opt.match_begin("-makecore=")))) {
    ver = regexp(args[opt], "-MAKECORE=(.*)$")[1];
    dblog("** Calling .make_core(\"" + ver + "\")..");
    .make_core(ver);
    return;
}

// Standard startup..
startup = startup.add('time, time());
backup = backup.add('next, time() + backup['interval]);

// In case we're recovering from a backup
if (dict_contains(backup, 'started))
    backup = dict_del(backup, 'started);
catch any {
    // get back the heartbeat
    set_heartbeat(startup['heartbeat_interval]);

    // Bind functions for security
    for f in (bindings) {
        catch any
            bind_function(@f);
        with
            dblog("** Unable to bind function " + f[1] + "() to " + f[2]);
    }

    // tell objects who should know, that we are online
    if (type(args) != 'list)
        args = [];
    for obj in (startup['objects]) {
        .log("Calling " + obj + ".startup()");
        catch any
            (> obj.startup(@args) <);
        with
            .log($parse_lib.traceback(traceback()));
    }
} with {
    .log("** Startup ERROR at " + ctime() + ":");
    .log(toliteral(traceback()));
    .log($parse_lib.traceback(traceback(), -1, ""));
}

// $#Edited: 18 Aug 97 10:25 $brandon
// $#Edited: 27 Dec 98 21:07 $brian
// $#Edited: 11 Feb 99 04:19 $brandon
// $#Edited: 19 Jul 99 11:18 $miro

["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]

the Cold Dark