list<pair<unsigned,unsigned>> stop_command_offsets;
string pid_file;
- service_type service_type = service_type::PROCESS;
+ service_type_t service_type = service_type_t::PROCESS;
std::list<prelim_dep> depends;
string logfile;
onstart_flags_t onstart_flags;
else if (setting == "type") {
string type_str = read_setting_value(i, end);
if (type_str == "scripted") {
- service_type = service_type::SCRIPTED;
+ service_type = service_type_t::SCRIPTED;
}
else if (type_str == "process") {
- service_type = service_type::PROCESS;
+ service_type = service_type_t::PROCESS;
}
else if (type_str == "bgprocess") {
- service_type = service_type::BGPROCESS;
+ service_type = service_type_t::BGPROCESS;
}
else if (type_str == "internal") {
- service_type = service_type::INTERNAL;
+ service_type = service_type_t::INTERNAL;
}
else {
throw service_description_exc(name, "Service type must be one of: \"scripted\","
service_file.close();
- if (service_type == service_type::PROCESS || service_type == service_type::BGPROCESS || service_type == service_type::SCRIPTED) {
+ if (service_type == service_type_t::PROCESS || service_type == service_type_t::BGPROCESS || service_type == service_type_t::SCRIPTED) {
if (command.length() == 0) {
throw service_description_exc(name, "Service command not specified");
}
if (*iter == rval) {
// We've found the dummy record
delete rval;
- if (service_type == service_type::PROCESS) {
+ if (service_type == service_type_t::PROCESS) {
auto rvalps = new process_service(this, string(name), std::move(command),
command_offsets, depends);
rvalps->set_restart_interval(restart_interval, max_restarts);
rvalps->set_start_interruptible(start_is_interruptible);
rval = rvalps;
}
- else if (service_type == service_type::BGPROCESS) {
+ else if (service_type == service_type_t::BGPROCESS) {
auto rvalps = new bgproc_service(this, string(name), std::move(command),
command_offsets, depends);
rvalps->set_pid_file(std::move(pid_file));
rvalps->set_start_interruptible(start_is_interruptible);
rval = rvalps;
}
- else if (service_type == service_type::SCRIPTED) {
+ else if (service_type == service_type_t::SCRIPTED) {
auto rvalps = new scripted_service(this, string(name), std::move(command),
command_offsets, depends);
rvalps->set_stop_command(stop_command, stop_command_offsets);
};
/* Service types */
-enum class service_type {
+enum class service_type_t {
DUMMY, // Dummy service, used to detect cyclice dependencies
PROCESS, // Service runs as a process, and can be stopped by
// sending the process a signal (usually SIGTERM)
}
else {
// exec() succeeded.
- if (sr->get_type() == service_type::PROCESS) {
+ if (sr->get_type() == service_type_t::PROCESS) {
// This could be a smooth recovery (state already STARTED). Even more, the process
// might be stopped (and killed via a signal) during smooth recovery. We don't to
// process startup again in either case, so we check for state STARTING:
// In most cases, the rest is done in handle_exit_status.
// If we are a BGPROCESS and the process is not our immediate child, however, that
// won't work - check for this now:
- if (get_type() == service_type::BGPROCESS && ! tracking_child) {
+ if (get_type() == service_type_t::BGPROCESS && ! tracking_child) {
stopped();
}
else if (stop_timeout != time_val(0,0)) {
// In most cases, the rest is done in handle_exit_status.
// If we are a BGPROCESS and the process is not our immediate child, however, that
// won't work - check for this now:
- if (get_type() == service_type::BGPROCESS && ! tracking_child) {
+ if (get_type() == service_type_t::BGPROCESS && ! tracking_child) {
stopped();
}
else if (stop_timeout != time_val(0,0)) {
}
base_process_service::base_process_service(service_set *sset, string name,
- service_type service_type_p, string &&command,
+ service_type_t service_type_p, string &&command,
std::list<std::pair<unsigned,unsigned>> &command_offsets,
const std::list<prelim_dep> &deplist_p)
: service_record(sset, name, service_type_p, deplist_p), child_listener(this),
private:
string service_name;
- service_type record_type; /* ServiceType::DUMMY, PROCESS, SCRIPTED, INTERNAL */
+ service_type_t record_type; /* ServiceType::DUMMY, PROCESS, SCRIPTED, INTERNAL */
service_state_t service_state = service_state_t::STOPPED; /* service_state_t::STOPPED, STARTING, STARTED, STOPPING */
service_state_t desired_state = service_state_t::STOPPED; /* service_state_t::STOPPED / STARTED */
{
services = set;
service_name = name;
- record_type = service_type::DUMMY;
+ record_type = service_type_t::DUMMY;
socket_perms = 0;
exit_status = 0;
}
- service_record(service_set *set, string name, service_type record_type_p,
+ service_record(service_set *set, string name, service_type_t record_type_p,
const std::list<prelim_dep> &deplist_p)
: service_record(set, name)
{
}
// Get the type of this service record
- service_type get_type() noexcept
+ service_type_t get_type() noexcept
{
return record_type;
}
bool isDummy() noexcept
{
- return record_type == service_type::DUMMY;
+ return record_type == service_type_t::DUMMY;
}
// Add a listener. A listener must only be added once. May throw std::bad_alloc.
void kill_pg(int signo) noexcept;
public:
- base_process_service(service_set *sset, string name, service_type record_type_p, string &&command,
+ base_process_service(service_set *sset, string name, service_type_t record_type_p, string &&command,
std::list<std::pair<unsigned,unsigned>> &command_offsets,
const std::list<prelim_dep> &deplist_p);
process_service(service_set *sset, string name, string &&command,
std::list<std::pair<unsigned,unsigned>> &command_offsets,
std::list<prelim_dep> depends_p)
- : base_process_service(sset, name, service_type::PROCESS, std::move(command), command_offsets,
+ : base_process_service(sset, name, service_type_t::PROCESS, std::move(command), command_offsets,
depends_p)
{
}
bgproc_service(service_set *sset, string name, string &&command,
std::list<std::pair<unsigned,unsigned>> &command_offsets,
std::list<prelim_dep> depends_p)
- : base_process_service(sset, name, service_type::BGPROCESS, std::move(command), command_offsets,
+ : base_process_service(sset, name, service_type_t::BGPROCESS, std::move(command), command_offsets,
depends_p)
{
}
scripted_service(service_set *sset, string name, string &&command,
std::list<std::pair<unsigned,unsigned>> &command_offsets,
std::list<prelim_dep> depends_p)
- : base_process_service(sset, name, service_type::SCRIPTED, std::move(command), command_offsets,
+ : base_process_service(sset, name, service_type_t::SCRIPTED, std::move(command), command_offsets,
depends_p)
{
}
class test_service : public service_record
{
public:
- test_service(service_set *set, std::string name, service_type type_p,
+ test_service(service_set *set, std::string name, service_type_t type_p,
const std::list<prelim_dep> &deplist_p)
: service_record(set, name, type_p, deplist_p)
{
{
service_set sset;
- service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
- service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
- service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+ service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+ service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
sset.add_service(s1);
sset.add_service(s2);
sset.add_service(s3);
{
service_set sset;
- service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
- service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
- service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
- service_record *s4 = new service_record(&sset, "test-service-4", service_type::INTERNAL, {{s2, REG}});
+ service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+ service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
+ service_record *s4 = new service_record(&sset, "test-service-4", service_type_t::INTERNAL, {{s2, REG}});
sset.add_service(s1);
sset.add_service(s2);
sset.add_service(s3);
{
service_set sset;
- service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
- service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
- service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+ service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+ service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
sset.add_service(s1);
sset.add_service(s2);
sset.add_service(s3);
{
service_set sset;
- service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
- service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
- service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+ service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+ service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
s2->set_auto_restart(true);
sset.add_service(s1);
sset.add_service(s2);
{
service_set sset;
- test_service *s1 = new test_service(&sset, "test-service-1", service_type::INTERNAL, {});
- test_service *s2 = new test_service(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
- test_service *s3 = new test_service(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+ test_service *s1 = new test_service(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ test_service *s2 = new test_service(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+ test_service *s3 = new test_service(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
sset.add_service(s1);
sset.add_service(s2);
{
service_set sset;
- service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
- service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
- service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+ service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+ service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
s2->set_auto_restart(true);
sset.add_service(s1);
sset.add_service(s2);
{
service_set sset;
- service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
- service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
- service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, WAITS}});
+ service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+ service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, WAITS}});
sset.add_service(s1);
sset.add_service(s2);
sset.add_service(s3);
{
service_set sset;
- service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
- service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, MS}});
+ service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, MS}});
sset.add_service(s1);
sset.add_service(s2);
{
service_set sset;
- test_service *s1 = new test_service(&sset, "test-service-1", service_type::INTERNAL, {});
- test_service *s2 = new test_service(&sset, "test-service-2", service_type::INTERNAL, {{s1, MS}});
+ test_service *s1 = new test_service(&sset, "test-service-1", service_type_t::INTERNAL, {});
+ test_service *s2 = new test_service(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, MS}});
sset.add_service(s1);
sset.add_service(s2);