1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-15 18:50:09 +03:00

feature #1683: Renamed Nebula::init() to Nebula::bootstrap_db()

This commit is contained in:
Ruben S. Montero 2013-10-09 18:39:18 +02:00
parent 4cc34621ec
commit 09fe471af6
3 changed files with 39 additions and 39 deletions

View File

@ -346,7 +346,7 @@ public:
/**
* Initialize the database
*/
void init();
void bootstrap_db();
// -----------------------------------------------------------------------
// Configuration attributes (read from oned.conf)

View File

@ -268,7 +268,7 @@ int SystemDB::select_sys_attribute(const string& attr_name, string& attr_xml)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void Nebula::init()
void Nebula::bootstrap_db()
{
start(true);
}

View File

@ -59,12 +59,12 @@ static void oned_init()
try
{
Nebula& nd = Nebula::instance();
nd.init();
nd.bootstrap_db();
}
catch (exception &e)
{
cerr << e.what() << endl;
return;
}
}
@ -77,19 +77,19 @@ static void oned_main()
try
{
Nebula& nd = Nebula::instance();
nd.start();
nd.start();
}
catch (exception &e)
{
cerr << e.what() << endl;
return;
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv)
{
int opt;
@ -99,7 +99,7 @@ int main(int argc, char **argv)
pid_t pid,sid;
string wd;
int rc;
while((opt = getopt(argc,argv,"vhif")) != -1)
switch(opt)
{
@ -117,7 +117,7 @@ int main(int argc, char **argv)
break;
case 'f':
foreground = true;
break;
break;
default:
cerr << susage;
exit(-1);
@ -125,24 +125,24 @@ int main(int argc, char **argv)
}
// ---------------------------------
// Check if other oned is running
// ---------------------------------
// Check if other oned is running
// ---------------------------------
string lockfile;
string var_location;
nl = getenv("ONE_LOCATION");
if (nl == 0) // OpenNebula in root of FSH
{
var_location = "/var/lib/one/";
var_location = "/var/lib/one/";
lockfile = "/var/lock/one/one";
}
else
{
var_location = nl;
var_location += "/var/";
lockfile = var_location + ".lock";
}
@ -150,70 +150,70 @@ int main(int argc, char **argv)
if( fd == -1)
{
cerr<< "Error: Cannot start oned, opening lock file " << lockfile
cerr<< "Error: Cannot start oned, opening lock file " << lockfile
<< endl;
exit(-1);
}
close(fd);
// ----------------------------
// Fork & exit main process
// ----------------------------
// ----------------------------
// Fork & exit main process
// ----------------------------
if (foreground == true)
{
pid = 0; //Do not fork
}
else
{
pid = fork();
pid = fork();
}
switch (pid){
case -1: // Error
cerr << "Error: Unable to fork.\n";
cerr << "Error: Unable to fork.\n";
exit(-1);
case 0: // Child process
rc = chdir(var_location.c_str());
if (rc != 0)
{
goto error_chdir;
}
if (foreground == false)
{
{
sid = setsid();
if (sid == -1)
{
goto error_sid;
}
}
oned_main();
unlink(lockfile.c_str());
unlink(lockfile.c_str());
break;
default: // Parent process
break;
break;
}
return 0;
error_chdir:
cerr << "Error: cannot change to dir " << wd << "\n";
unlink(lockfile.c_str());
exit(-1);
error_sid:
error_sid:
cerr << "Error: creating new session\n";
unlink(lockfile.c_str());
exit(-1);