StateFile: configurable interval
This commit is contained in:
parent
d383d617c2
commit
42af040fbd
12
doc/user.xml
12
doc/user.xml
@ -898,6 +898,18 @@ systemctl start mpd.socket</programlisting>
|
|||||||
(<parameter>+wx</parameter>).
|
(<parameter>+wx</parameter>).
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry>
|
||||||
|
<varname>state_file_interval</varname>
|
||||||
|
<parameter>SECONDS</parameter>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
Auto-save the state file this number of seconds
|
||||||
|
after each state change. Defaults to
|
||||||
|
<parameter>120</parameter> (2 minutes).
|
||||||
|
</entry>
|
||||||
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
|
@ -279,7 +279,10 @@ glue_state_file_init(Error &error)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
state_file = new StateFile(std::move(path_fs),
|
unsigned interval = config_get_unsigned(CONF_STATE_FILE_INTERVAL,
|
||||||
|
StateFile::DEFAULT_INTERVAL);
|
||||||
|
|
||||||
|
state_file = new StateFile(std::move(path_fs), interval,
|
||||||
*instance->partition,
|
*instance->partition,
|
||||||
*instance->event_loop);
|
*instance->event_loop);
|
||||||
state_file->Read();
|
state_file->Read();
|
||||||
|
@ -36,10 +36,11 @@
|
|||||||
|
|
||||||
static constexpr Domain state_file_domain("state_file");
|
static constexpr Domain state_file_domain("state_file");
|
||||||
|
|
||||||
StateFile::StateFile(AllocatedPath &&_path,
|
StateFile::StateFile(AllocatedPath &&_path, unsigned _interval,
|
||||||
Partition &_partition, EventLoop &_loop)
|
Partition &_partition, EventLoop &_loop)
|
||||||
:TimeoutMonitor(_loop),
|
:TimeoutMonitor(_loop),
|
||||||
path(std::move(_path)), path_utf8(path.ToUTF8()),
|
path(std::move(_path)), path_utf8(path.ToUTF8()),
|
||||||
|
interval(_interval),
|
||||||
partition(_partition),
|
partition(_partition),
|
||||||
prev_volume_version(0), prev_output_version(0),
|
prev_volume_version(0), prev_output_version(0),
|
||||||
prev_playlist_version(0)
|
prev_playlist_version(0)
|
||||||
@ -137,7 +138,7 @@ void
|
|||||||
StateFile::CheckModified()
|
StateFile::CheckModified()
|
||||||
{
|
{
|
||||||
if (!IsActive() && IsModified())
|
if (!IsActive() && IsModified())
|
||||||
ScheduleSeconds(2 * 60);
|
ScheduleSeconds(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -34,6 +34,8 @@ class StateFile final : private TimeoutMonitor {
|
|||||||
const AllocatedPath path;
|
const AllocatedPath path;
|
||||||
const std::string path_utf8;
|
const std::string path_utf8;
|
||||||
|
|
||||||
|
const unsigned interval;
|
||||||
|
|
||||||
Partition &partition;
|
Partition &partition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +46,10 @@ class StateFile final : private TimeoutMonitor {
|
|||||||
prev_playlist_version;
|
prev_playlist_version;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StateFile(AllocatedPath &&path, Partition &partition, EventLoop &loop);
|
static constexpr unsigned DEFAULT_INTERVAL = 2 * 60;
|
||||||
|
|
||||||
|
StateFile(AllocatedPath &&path, unsigned interval,
|
||||||
|
Partition &partition, EventLoop &loop);
|
||||||
|
|
||||||
void Read();
|
void Read();
|
||||||
void Write();
|
void Write();
|
||||||
|
@ -32,6 +32,7 @@ enum ConfigOption {
|
|||||||
CONF_LOG_FILE,
|
CONF_LOG_FILE,
|
||||||
CONF_PID_FILE,
|
CONF_PID_FILE,
|
||||||
CONF_STATE_FILE,
|
CONF_STATE_FILE,
|
||||||
|
CONF_STATE_FILE_INTERVAL,
|
||||||
CONF_RESTORE_PAUSED,
|
CONF_RESTORE_PAUSED,
|
||||||
CONF_USER,
|
CONF_USER,
|
||||||
CONF_GROUP,
|
CONF_GROUP,
|
||||||
|
@ -32,6 +32,7 @@ const ConfigTemplate config_templates[] = {
|
|||||||
{ "log_file", false, false },
|
{ "log_file", false, false },
|
||||||
{ "pid_file", false, false },
|
{ "pid_file", false, false },
|
||||||
{ "state_file", false, false },
|
{ "state_file", false, false },
|
||||||
|
{ "state_file_interval", false, false },
|
||||||
{ "restore_paused", false, false },
|
{ "restore_paused", false, false },
|
||||||
{ "user", false, false },
|
{ "user", false, false },
|
||||||
{ "group", false, false },
|
{ "group", false, false },
|
||||||
|
Loading…
Reference in New Issue
Block a user