Exemple #1
0
int main(int argc, char *argv[]) {
	const char *config = "config";
	struct pixel_config cfg;
	lua_State *L;
	if (argc > 1) {
		config = argv[1];
	}
	signin();
	pixel_init();
	L = luaL_newstate();
	if (LUA_OK != luaL_dofile(L, config)) {
		fprintf(stderr, "load config:%s\n", lua_tostring(L, -1));
		return 1;
	}
	_init_env(L);
	cfg.thread = optint("thread", 8);
	cfg.harbor = optint("harbor", 1);
	cfg.module_path = optstring("cservice", "./?.so");
	cfg.bootstrap = optstring("bootstrap", "lua bootstrap");
	cfg.logfile = optstring("log", 0);
	lua_close(L);
	pixel_start(&cfg);
	pixel_unit();
	return 0;
}
int
main(int argc, char *argv[]) {
	const char * config_file = "config";
	if (argc > 1) {
		config_file = argv[1];
	}
	skynet_env_init();

	sigign();

	struct skynet_config config;

	// lua 相关的一些初始化
	struct lua_State *L = luaL_newstate();
	luaL_openlibs(L);	// link lua lib
	lua_close(L);

	L = luaL_newstate();

	int err = luaL_dofile(L, config_file);
	if (err) {
		fprintf(stderr,"%s\n",lua_tostring(L,-1));
		lua_close(L);
		return 1;
	} 

	// 初始化 lua 环境
	_init_env(L);

	const char *path = optstring("lua_path","./lualib/?.lua;./lualib/?/init.lua");
	setenv("LUA_PATH",path,1);

	const char *cpath = optstring("lua_cpath","./luaclib/?.so");
	setenv("LUA_CPATH",cpath,1);
	optstring("luaservice","./service/?.lua");

	// 加载配置项
	config.thread =  optint("thread",8);
	config.module_path = optstring("cpath","./service/?.so");
	config.logger = optstring("logger",NULL);
	config.harbor = optint("harbor", 1);
	config.master = optstring("master","127.0.0.1:2012");
	config.start = optstring("start","main.lua");
	config.local = optstring("address","127.0.0.1:2525");
	config.standalone = optstring("standalone",NULL);

	lua_close(L);

	skynet_start(&config);

	printf("skynet exit\n");

	return 0;
}
Exemple #3
0
static void
sc_env_load(const char* file) {
    lua_State* L = luaL_newstate();
    luaL_openlibs(L);
    if (luaL_dofile(L, file) != LUA_OK) {
        fprintf(stderr, "Error load config file, %s\n", lua_tostring(L, -1));
        exit(1);
    }
    _init_env(L); 
    lua_close(L);
}
Exemple #4
0
int
main(int argc, char *argv[]) {
	const char * config_file = NULL ;
	if (argc > 1) {
		config_file = argv[1];
	} else {
		fprintf(stderr, "Need a config file.\n");
		return 1;
	}
	server_globalinit();
	server_env_init();

	sigign();
	server_pid = (int)getpid();

	struct server_config config;

	struct lua_State *L = lua_newstate(server_lalloc, NULL);
	luaL_openlibs(L);

	int r = luaL_loadfile(L, config_file);
	if (r) {
		fprintf(stderr,"luaL_loadfile err:%s\n",lua_tostring(L,-1));
		lua_close(L);
		return 1;
	} 
	int err = lua_pcall(L,0,1,0);
	if (err) {
		fprintf(stderr,"lua_pcall config file err:%s\n",lua_tostring(L,-1));
		lua_close(L);
		return 1;
	} 
	_init_env(L);

	config.harbor = optint("harbor", 1);
	config.thread =  optint("thread",8);
	config.logger = optstring("logger", NULL);
	config.bootstrap = optstring("bootstrap","snlua bootstrap");
	config.module_path = optstring("cpath","./cservice/?.so");

	lua_close(L);
	
	//启动服务
	server_start(&config);
	
	return 0;
}
int
main(int argc, char *argv[]) {
	const char * config_file = "config";
	if (argc > 1) {
		config_file = argv[1];
	}
	skynet_globalinit();
	skynet_env_init();

#if !defined(__WIN32__)
	sigign();
#endif

	struct skynet_config config;

	struct lua_State *L = lua_newstate(skynet_lalloc, NULL);
	luaL_openlibs(L);	// link lua lib
	lua_close(L);

	L = luaL_newstate();

	int err = luaL_dofile(L, config_file);
	if (err) {
		fprintf(stderr,"%s\n",lua_tostring(L,-1));
		lua_close(L);
		return 1;
	} 
	_init_env(L);

#ifdef LUA_CACHELIB
  printf("Skynet lua code cache enable\n");
#endif

	config.thread =  optint("thread",8);
	config.module_path = optstring("cpath","./cservice/?.dll");
	config.harbor = optint("harbor", 1);
	config.bootstrap = optstring("bootstrap","snlua bootstrap");

	lua_close(L);

	skynet_start(&config);
	skynet_globalexit();

	printf("skynet exit\n");

	return 0;
}
Exemple #6
0
int
main(int argc, char *argv[]) {
#if defined(__WIN32__)
	WSADATA WSAData;

	if(WSAStartup(MAKEWORD(2, 2), &WSAData))//初始化
	{
		printf("initializationing error!\n");
		WSACleanup();
		exit(0);
	}
#endif

	const char * config_file = "config";
	if (argc > 1) {
		config_file = argv[1];
	}
	skynet_globalinit();
	skynet_env_init();

#if !defined(__WIN32__)
	sigign();
#endif

	struct skynet_config config;

	struct lua_State *L = lua_newstate(skynet_lalloc, NULL);
	luaL_openlibs(L);	// link lua lib
	lua_close(L);

	L = luaL_newstate();

	int err = luaL_dofile(L, config_file);
	if (err) {
		fprintf(stderr,"%s\n",lua_tostring(L,-1));
		lua_close(L);
		return 1;
	} 
	_init_env(L);

#ifdef LUA_CACHELIB
  printf("Skynet lua code cache enable\n");
#endif

	config.thread =  optint("thread",8);
	config.module_path = optstring("cpath","./cservice/?.so");
	config.logger = optstring("logger",NULL);
	config.harbor = optint("harbor", 1);
	config.master = optstring("master","127.0.0.1:2012");
	config.bootstrap = optstring("bootstrap","snlua bootstrap");
	config.local = optstring("address","127.0.0.1:2525");
	config.standalone = optstring("standalone",NULL);

	lua_close(L);

	skynet_start(&config);
	skynet_globalexit();

	printf("skynet exit\n");

	return 0;
}
/** For testing via the cmd line */
void main(int argc, char** argv)
{
	// Initialize the DBus connection
	_Env env;
	if (!_init_env(&env, NULL))
	{
		printf("Environment not initialized. Exit.\n");
		return;
	}
	
	// Open a session for the secret service
	char* session = _dbus_secret_session_open(&env);
	if (session == NULL)
	{
		printf("Session not created. Exit.\n");
		return;
	}
	printf("session: %s\n", session);
	
	// Search for the stored secret
	char* path = _dbus_secret_search(&env, "org.eclipse.equinox.internal.security.linux", "mpdeimos", "master");
	if (path == NULL) // Secret not found
	{
		printf("path: %s\n", "NULL");
		
		// Create a new password
		path = _dbus_secret_create(&env, session, "org.eclipse.equinox.internal.security.linux", "mpdeimos", "master", "foo");
		if (path == NULL)
		{
			printf("Secret not created. Exit.\n");
			return;
		}
		printf("path: %s\n", path);
		
		// Search for the new password
		path = _dbus_secret_search(&env, "org.eclipse.equinox.internal.security.linux", "mpdeimos", "master");
		if (path == NULL)
		{
			printf("Secret not searchable. Exit.\n");
			return;
		}

	}
	printf("path: %s\n", path);
	
	// Get the actual password string
	char* secret = _dbus_secret_get(&env, session, path);
	if (secret == NULL)
	{
		printf("Secret not retrievable. Exit.\n");
		return;
	}
	printf("secret: %s\n", secret);
	
	// Close the secret service session
	_dbus_secret_session_close(&env, session);
	
	_free_env(&env);
	
	// Free allocated data
	free(secret);
	free(path);
	free(session);
}
Exemple #8
0
void initc(void)
{
    PyObject *m = Py_InitModule3("c", c_funcs, "C repository types module");

    Empty_TUPLE = PyTuple_New(0);
    None_PAIR = PyTuple_Pack(2, Py_None, Py_None);

    _init_view(m);
    _init_repository(m);
    _init_container(m);
    _init_sequence(m);
    _init_db(m);
    _init_cursor(m);
    _init_env(m);
    _init_txn(m);
    _init_lock(m);
    _init_record(m);
    _init_store(m);

    PyExc_DBError = PyErr_NewException("chandlerdb.persistence.c.DBError",
                                       NULL, NULL);
    PyObject_SetAttrString(m, "DBError", PyExc_DBError);

    MAKE_EXC(m, DBLockDeadlockError, DBError);
    MAKE_EXC(m, DBLockNotGrantedError, DBError);
    MAKE_EXC(m, DBAccessError, DBError);
    MAKE_EXC(m, DBBusyError, DBError);
    MAKE_EXC(m, DBInvalidArgError, DBError);
    MAKE_EXC(m, DBNoSpaceError, DBError);
    MAKE_EXC(m, DBNotFoundError, DBError);
    MAKE_EXC(m, DBNoSuchFileError, DBError);
    MAKE_EXC(m, DBPermissionsError, DBError);
    MAKE_EXC(m, DBVersionMismatchError, DBError);
    MAKE_EXC(m, DBRunRecoveryError, DBError);

    PyModule_AddIntConstant(m, "DB_VERSION_MAJOR", DB_VERSION_MAJOR);
    PyModule_AddIntConstant(m, "DB_VERSION_MINOR", DB_VERSION_MINOR);
    PyModule_AddIntConstant(m, "DB_VERSION_PATCH", DB_VERSION_PATCH);

    if (!(m = PyImport_ImportModule("chandlerdb.util.c")))
        return;
    LOAD_FN(m, PyUUID_Check);
    LOAD_FN(m, PyUUID_Make16);
    LOAD_FN(m, _hash_bytes);
    LOAD_OBJ(m, Nil);
    LOAD_TYPE(m, CtxMgr);
    LOAD_TYPE(m, SkipList);
    SkipList_Node = (PyTypeObject *)
        PyObject_GetAttrString((PyObject *) SkipList, "Node");
    Py_DECREF(m);

    if (!(m = PyImport_ImportModule("chandlerdb.item.c")))
        return;
    LOAD_TYPE(m, CItem);
    LOAD_TYPE(m, ItemRef);
    LOAD_FN(m, CItem_getLocalAttributeValue);
    Py_DECREF(m);

    if (!(m = PyImport_ImportModule("chandlerdb.schema.c")))
        return;
    LOAD_FN(m, CAttribute_invokeAfterChange);
    Py_DECREF(m);
}