Exemple #1
0
        virtual void Run()
        {
            int32_t argc = m_argc;
            char** argv = m_argv;

            exlib::string exePath;
            std::vector<char*> ptrArg;

            process_base::get_execPath(exePath);

            bool bZip;
            ifZipFile(exePath, bZip);
            if (bZip) {

                exePath.append(1, '$');
                ptrArg.resize(argc + 1);

                ptrArg[0] = argv[0];
                ptrArg[1] = exePath.c_buffer();

                int32_t i;
                for (i = 1; i < argc; i++)
                    ptrArg[i + 1] = argv[i];

                argv = &ptrArg[0];
                argc++;
            }

            init_start_argv(argc, argv);

            int32_t pos = argc;
            options(pos, argv);

            init();

            if (pos < argc) {
                if (argv[pos][0] == '-')
                    m_start = argv[pos];
                else {
                    m_start = s_root;
                    resolvePath(m_start, argv[pos]);
                }

                if (pos != 1) {
                    int32_t p = 1;
                    for (; pos < argc; pos++)
                        argv[p++] = argv[pos];
                    argc = p;
                }
            }

            init_argv(argc, argv);
            exlib::Service::Create(start_fiber, this, 256 * 1024, "start");

            m_sem.Post();
            exlib::Service::dispatch();
        }
Exemple #2
0
void init(int32_t argc, char *argv[])
{
    ::setlocale(LC_ALL, "");

    int32_t cpus = 0;

    os_base::CPUs(cpus);
    if (cpus < 2)
        cpus = 2;

    exlib::Service::init(cpus + 1);

    init_start_argv(argc, argv);

    if (options(&argc, argv))
        _exit(0);

    init_prof();
    init_argv(argc, argv);
    init_date();
    init_rt();
    init_sandbox();
    init_cipher();
    init_acThread();
    init_logger();
    init_aio();
    init_fiber();

    srand((unsigned int)time(0));

    v8::Platform *platform = v8::platform::CreateDefaultPlatform();
    v8::V8::InitializePlatform(platform);

    v8::V8::Initialize();

    init_Task(cpus);
}