SystemctlD nodejs apps #12

Open
opened 2024-07-05 16:02:21 +07:00 by sas.padmanto · 1 comment
Owner

pastikan nodejs sudah terinstall

node --version
v18.19.1

create file service
/usr/lib/systemd/service/etlmcu.service

[Unit]
Description=EtlMcu service
ConditionPathExists=/home/one/project/ts-etl-mcu
After=network.target
StartLimitIntervalSec=60

[Service]
Type=simple
User=one
Group=one
LimitNOFILE=1024

Restart=on-failure
RestartSec=10

WorkingDirectory=/home/one/project/ts-etl-mcu
ExecStart=/usr/bin/node one-etl-mcu-gw.js


# make sure log directory exists and owned by syslog
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/log/etlmcu
ExecStartPre=/bin/chown syslog:one /var/log/etlmcu
ExecStartPre=/bin/chmod 755 /var/log/etlmcu
SyslogIdentifier=etlmcu

[Install]
WantedBy=multi-user.target
pastikan nodejs sudah terinstall ```bash node --version v18.19.1 ``` create file service /usr/lib/systemd/service/etlmcu.service ```yaml [Unit] Description=EtlMcu service ConditionPathExists=/home/one/project/ts-etl-mcu After=network.target StartLimitIntervalSec=60 [Service] Type=simple User=one Group=one LimitNOFILE=1024 Restart=on-failure RestartSec=10 WorkingDirectory=/home/one/project/ts-etl-mcu ExecStart=/usr/bin/node one-etl-mcu-gw.js # make sure log directory exists and owned by syslog PermissionsStartOnly=true ExecStartPre=/bin/mkdir -p /var/log/etlmcu ExecStartPre=/bin/chown syslog:one /var/log/etlmcu ExecStartPre=/bin/chmod 755 /var/log/etlmcu SyslogIdentifier=etlmcu [Install] WantedBy=multi-user.target ```
Author
Owner

update syslog config, for special log file

/etc/rsyslog.d/030-etlmcu.conf

if $programname == 'etlmcu' then /var/log/etlmcu/etlmcu.log
& stop
update syslog config, for special log file /etc/rsyslog.d/030-etlmcu.conf ```bash if $programname == 'etlmcu' then /var/log/etlmcu/etlmcu.log & stop ```
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: andy/corporate_portal_westerindo#12