Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engine: Set shm path to "app/$name" #766

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/core/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local lib = require("core.lib")
local link = require("core.link")
local config = require("core.config")
local timer = require("core.timer")
local shm = require("core.shm")
local counter = require("core.counter")
local zone = require("jit.zone")
local ffi = require("ffi")
Expand Down Expand Up @@ -65,6 +66,8 @@ end
-- Run app:methodname() in protected mode (pcall). If it throws an
-- error app will be marked as dead and restarted eventually.
local function with_restart (app, method)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should rename with_restart to something like invoke_app_method. Nothing critical but this change makes the functions name a misnomer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukego Do you want to rename with_restart before I merge this or leave it as is?

local oldshm = shm.path
shm.path = app.shmpath
if use_restart then
-- Run fn in protected mode using pcall.
local status, err = pcall(method, app)
Expand All @@ -75,6 +78,7 @@ local function with_restart (app, method)
else
method(app)
end
shm.path = oldshm
end

-- Restart dead apps.
Expand Down Expand Up @@ -162,7 +166,11 @@ function apply_config_actions (actions, conf)
function ops.start (name)
local class = conf.apps[name].class
local arg = conf.apps[name].arg
local shmpath, shmorig = "app/"..name, shm.path
shm.path = shmpath
local app = class:new(arg)
shm.path = shmorig
local shmpath = "app/"..name
if type(app) ~= 'table' then
error(("bad return value from app '%s' start() method: %s"):format(
name, tostring(app)))
Expand All @@ -171,6 +179,7 @@ function apply_config_actions (actions, conf)
app.appname = name
app.output = {}
app.input = {}
app.shmpath = shmpath
new_app_table[name] = app
table.insert(new_app_array, app)
app_name_to_index[name] = #new_app_array
Expand Down