Skip to content

Commit

Permalink
Showing 8 changed files with 43 additions and 36 deletions.
4 changes: 2 additions & 2 deletions library/rubinius/configuration.rb
Original file line number Diff line number Diff line change
@@ -176,7 +176,7 @@
s.vm_variable "tmp", "$TMPDIR",
"Default temp/fallback directory for the process"

s.vm_variable "fsapi.path", "$TMPDIR",
s.vm_variable "fsapi.path", "$TMPDIR/$PROGRAM_NAME-$USER-$PID",
"Base directory of the Rubinius File System API files"

s.vm_variable "fsapi.access", 0750,
@@ -185,7 +185,7 @@
s.vm_variable "console.access", 0660,
"Permissions on the Rubinius Console files"

s.vm_variable "log", "$TMPDIR/$USER-$PROGRAM_NAME.log",
s.vm_variable "log", "$TMPDIR/$PROGRAM_NAME-$USER.log",
"Logging facility to use: 'syslog', 'console', or path"

s.vm_variable "log.level", "warn",
5 changes: 5 additions & 0 deletions vm/console.cpp
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@ namespace rubinius {
: InternalThread(state, "rbx.console.request")
, console_(console)
, response_(console->response())
, enabled_(false)
, fd_(-1)
, fsevent_(state)
{
@@ -74,6 +75,8 @@ namespace rubinius {
FSEvent* fsevent = FSEvent::create(state);
fsevent->watch_file(state, fd_, path_.c_str());
fsevent_.set(fsevent);

enabled_ = true;
}

void Request::start_thread(STATE) {
@@ -152,6 +155,8 @@ namespace rubinius {
}

void Request::run(STATE) {
if(!enabled_) return;

while(!thread_exit_) {
Object* status = fsevent_.get()->wait_for_event(state);

2 changes: 2 additions & 0 deletions vm/console.hpp
Original file line number Diff line number Diff line change
@@ -89,6 +89,8 @@ namespace rubinius {
Console* console_;
Response* response_;

bool enabled_;

std::string path_;
int fd_;

59 changes: 26 additions & 33 deletions vm/environment.cpp
Original file line number Diff line number Diff line change
@@ -201,26 +201,9 @@ namespace rubinius {
} else if(!config.system_log.value.compare("console")) {
utilities::logger::open(utilities::logger::eConsoleLogger, RBX_PROGRAM_NAME, level);
} else {
const char* tmpdir = "$TMPDIR";
size_t index = config.system_log.value.find(tmpdir);

if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(tmpdir), config.system_tmp);
}

const char* program_name = "$PROGRAM_NAME";
index = config.system_log.value.find(program_name);

if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(program_name), RBX_PROGRAM_NAME);
}

const char* user = "$USER";
index = config.system_log.value.find(user);

if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(user), shared->username);
}
expand_config_value(config.system_log, "$TMPDIR", config.system_tmp);
expand_config_value(config.system_log, "$PROGRAM_NAME", RBX_PROGRAM_NAME);
expand_config_value(config.system_log, "$USER", shared->username.c_str());

utilities::logger::open(utilities::logger::eFileLogger,
config.system_log.value.c_str(), level);
@@ -313,9 +296,21 @@ namespace rubinius {

set_tmp_path();
set_username();
set_pid();

set_fsapi_path();
}

void Environment::expand_config_value(config::String& cvar,
const char* var, const char* value)
{
size_t index = cvar.value.find(var);

if(index != std::string::npos) {
cvar.value.replace(index, strlen(var), value);
}
}

void Environment::set_tmp_path() {
if(!config.system_tmp.value.compare("$TMPDIR")) {
std::ostringstream path;
@@ -338,21 +333,19 @@ namespace rubinius {
shared->username.assign(user_passwd->pw_name);
}

void Environment::set_fsapi_path() {
std::ostringstream path;

if(!config.system_fsapi_path.value.compare("$TMPDIR")) {
path << config.system_tmp.value;
} else {
std::string cpath = config.system_fsapi_path.value;

path << cpath;
if(cpath[cpath.size() - 1] != '/') path << "/";
}
void Environment::set_pid() {
std::ostringstream pid;
pid << getpid();
shared->pid.assign(pid.str());
}

path << "rbx-" << shared->username << "-" << getpid();
void Environment::set_fsapi_path() {
expand_config_value(config.system_fsapi_path, "$TMPDIR", config.system_tmp);
expand_config_value(config.system_fsapi_path, "$PROGRAM_NAME", RBX_PROGRAM_NAME);
expand_config_value(config.system_fsapi_path, "$USER", shared->username.c_str());
expand_config_value(config.system_fsapi_path, "$PID", shared->pid.c_str());

shared->fsapi_path.assign(path.str());
shared->fsapi_path.assign(config.system_fsapi_path.value);

create_fsapi(state);
}
2 changes: 2 additions & 0 deletions vm/environment.hpp
Original file line number Diff line number Diff line change
@@ -99,8 +99,10 @@ namespace rubinius {
void load_conf(std::string path);
void load_string(std::string str);
void run_file(std::string path);
void expand_config_value(config::String& cvar, const char* var, const char* value);
void set_tmp_path();
void set_username();
void set_pid();
void set_fsapi_path();
void load_tool();
void run_from_filesystem();
3 changes: 3 additions & 0 deletions vm/shared_state.cpp
Original file line number Diff line number Diff line change
@@ -53,6 +53,9 @@ namespace rubinius {
, config(config)
, user_variables(cp)
, llvm_state(0)
, fsapi_path("")
, username("")
, pid("")
{
ref();

2 changes: 2 additions & 0 deletions vm/shared_state.hpp
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@

#include "capi/capi_constants.h"

#include <unistd.h>
#include <string>
#include <vector>
#include <list>
@@ -143,6 +144,7 @@ namespace rubinius {
LLVMState* llvm_state;
std::string fsapi_path;
std::string username;
std::string pid;
uint32_t hash_seed;

public:
2 changes: 1 addition & 1 deletion vm/signal.cpp
Original file line number Diff line number Diff line change
@@ -350,7 +350,7 @@ namespace rubinius {

logger::fatal("--- begin rubinius info ---");
logger::fatal("user: %s", signal_thread_->shared().username.c_str());
logger::fatal("pid: %d", getpid());
logger::fatal("pid: %s", signal_thread_->shared().pid.c_str());
logger::fatal("program name: %s", RBX_PROGRAM_NAME);
logger::fatal("version: %s", RBX_VERSION);
logger::fatal("ruby version: %s", RBX_RUBY_VERSION);

0 comments on commit bf19334

Please sign in to comment.