Skip to content

Commit

Permalink
Eucanetd systemd mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sjones4 committed Mar 17, 2020
1 parent 57b9987 commit 969c696
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
17 changes: 11 additions & 6 deletions net/eucanetd.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ int main(int argc, char **argv) {

// parse commandline arguments
config->flushmode = FLUSH_NONE;
while ((opt = getopt(argc, argv, "dhHlgfFmMuUCZT:v:V:z:")) != -1) {
while ((opt = getopt(argc, argv, "dhHlgfFmMsuUCZT:v:V:z:")) != -1) {
switch (opt) {
case 'd':
config->debug = EUCANETD_DEBUG_TRACE;
Expand Down Expand Up @@ -373,6 +373,9 @@ int main(int argc, char **argv) {
config->flushmode = FLUSH_MIDO_DUPS;
config->debug = EUCANETD_DEBUG_INFO;
break;
case 's':
config->systemd = TRUE;
break;
case 'u':
config->flushmode = FLUSH_MIDO_CHECKUNCONNECTED;
config->debug = EUCANETD_DEBUG_INFO;
Expand Down Expand Up @@ -455,11 +458,13 @@ int main(int argc, char **argv) {
}
}

// daemonize this process!
rc = eucanetd_daemonize();
if (rc) {
fprintf(stderr, "failed to eucanetd_daemonize eucanetd, exiting\n");
exit(1);
if (!config->systemd) {
// daemonize this process!
rc = eucanetd_daemonize();
if (rc) {
fprintf(stderr, "failed to eucanetd_daemonize eucanetd, exiting\n");
exit(1);
}
}

eucanetd_setlog_bootstrap();
Expand Down
1 change: 1 addition & 0 deletions net/eucanetd.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ typedef struct eucanetdConfig_t {
boolean validate_mido_config;

int debug;
boolean systemd; //!< Set to TRUE to indicate systemd mode (do not switch user or daemonize)
int flushmode;
char *flushmodearg;
boolean multieucanetd_safe;
Expand Down
16 changes: 8 additions & 8 deletions systemd/units/eucanetd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ Description=Eucalyptus network daemon
After=midolman.service network.target

[Service]
Type=forking
Type=simple
PIDFile=/run/eucalyptus/eucanetd.pid
ExecStart=/usr/sbin/eucanetd
ExecStart=/usr/sbin/eucanetd -s
ExecStartPost=/bin/sh -c 'echo $MAINPID > /run/eucalyptus/eucanetd.pid'
LimitNOFILE=10000
LimitNPROC=100000
# Need to come up with a better way of preserving nginx and dhcpd
# processes across service restarts
# https://eucalyptus.atlassian.net/browse/EUCA-12390
#KillMode=process

# KillMode removed per http://eucalyptus.atlassian.net/browse/EUCA-12424
PrivateTmp=true
ProtectHome=true
ProtectSystem=true
User=eucalyptus
Group=eucalyptus

[Install]
WantedBy=multi-user.target
Expand Down

0 comments on commit 969c696

Please sign in to comment.