IPC
This page is up to date as of v0.7.0, lacking documentation for IPC events.
The IPC on Windows is available via named pipes and on Linux it's available at /tmp/CoreFxPipe_{JAND_PIPE}
.
Messages to the daemon are sent in the following JSON format:
{"Type":"packet-type","Data":"hey"}
Note that Data
must always be a string,
meaning when you're sending an object you have to convert it to a string.
Libraries
You can use the unofficial Node.js library jand-ipc.
Packet Types
exit
Kills all processes and exits the daemon.
status
Gets daemon status.
Example Response
{
"Processes": 10,
"NotSaved": true,
"Directory": "/etc/jand",
"Version": "0.5.1"
}
rename-process
Rename a process.
Data
{oldName}:{newName}
for example: oldTest:newTest
Response
ERR:already-exists
ERR:Process name doesn't pass verification regex.
done
send-process-stdin-line
Send a line to process' stdin.
Data
{ProcessName}:{text...}
for example: bash:sh -c sleep 1
Response
done
set-enabled
Set Enabled
of a process.
Data
{ProcessName}:{boolean}
for example: dbus:true
Response
The boolean value that was set, True
or False
.
set-process-property
Data
Response
Invalid property.
done
get-process-info
Data
The process' name.
Response
stop-process
Kill a process.
Data
The process' name.
Response
already-stopped
if not runningkilled
if killed succesfully.
restart-process
Restart a process.
Data
The process' name.
Response
done
new-process
Creates a new process, enables it but doesn't start it automatically.
Data
Response
added
ERR:already-exists
ERR:Process name doesn't pass verification regex.
start-process
Start an already existing process.
Data
The process' name.
Response
ERR:already-started
done
save-config
Make the daemon save it's configuration.
Response
done
get-processes
Response
An array of RuntimeProcessInfo.
delete-process
Kill a process and delete it.
Response
done
subscribe-events
Subscribe to events over IPC using a bitfield of events DaemonEvents.
Data
The events you want to subscribe to represented as a number. The events will be automatically added onto your already subscribed events using a bit-wise/binary OR operation.
Response
done
unsubscribe-events
Unsubscribe from IPC events. Same as subscribe-events
except it makes a XOR operation.
subscribe-outlog-event
Subscribe to stdout log events for a process.
Data
The process' name
Response
done
subscribe-errlog-event
Subscribe to stderr log events for a process.
Data
The process' name
Response
done
get-config
Get daemon configuration.
Response
{
"LogIpc": true,
"FormatConfig": true,
"MaxRestarts": 15,
"LogProcessOutput": true
}
set-config
Set daemon configuration. (to be changed)
Data
option:value
Response
Option not found.
done
flush-all-logs
Ensure all logs are written to disk. This may be redundant after version 0.6.0/commit 067c835
.
Response
done
IPC Objects
ProcessInfo
{
"Name": "jand",
"Filename": "/usr/bin/jand start-daemon",
"Arguments": [],
"WorkingDirectory": "/etc/jand",
"AutoRestart": true,
"Enabled": true
}
RuntimeProcessInfo
{
"Name": "jand",
"Filename": "/usr/bin/jand start-daemon",
"Arguments": [],
"WorkingDirectory": "/home/jan/.jand",
"ProcessId": -1,
"Stopped": true,
"ExitCode": 137,
"RestartCount": 1,
"AutoRestart": true,
"Running": false
}
NewProcess
{
"Name": "jand",
"Filename": "/usr/bin/jand start-daemon",
"Arguments": [],
"WorkingDirectory": "/etc/jand"
}
DaemonEvents
The comments represent their name when given over IPC.
[Flags]
public enum DaemonEvents
{
// outlog
OutLog = 0b0000_0001,
// errlog
ErrLog = 0b0000_0010,
// procstop
ProcessStopped = 0b0000_0100,
// procstart
ProcessStarted = 0b0000_1000,
// procadd
ProcessAdded = 0b0001_0000,
// procdel
ProcessDeleted = 0b0010_0000,
// procren
ProcessRenamed = 0b0100_0000,
}
SetPropertyIpcPacket
Note: Data must always be a string.
{
"Process": "processName",
"Property": "Enabled",
"Data": "false"
}