Running Node App as systemd Service

In this post we will be using systemd to run a node application. This is helpful as it will automatically start the app when the server starts so we don’t have to manually. These steps can easily be modified to run a bash script, or any other application.

  • Create systemd file
  • Customize systemd file
  • Enable systemd file

We’ll be creating a service for the Simple Whisper Web Interface as an example. Chang things as needed.

Create systemd file

This is super simple. We create a .service file in /lib/systemd/system. When we enable the service, it will create a symlink to this file.

sudo vim /lib/systemd/system/whisperweb.service

Customize systemd file

Change the settings as appropriate. It would be a good idea to run any service as a limited user that only has the rights needed to get the job done. Do note that you will need to have any prerequisites installed and available for that user to use. I.e. libraries installed with npm etc.

[Unit]
Description=Simple Whisper Web Interface Service File
After=network.target

[Service]
Type=simple
User=whisperuser
ExecStart=/usr/bin/node mainssl.js
WorkingDirectory=/home/whisperuser/
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable systemd file

Enabling the service will create a symlink that will then run this service file on system boot.

sudo systemctl enable whisperweb.service

And now we can start the service.

sudo systemctl start whisperweb.service

We can verify that the service is running by running

sudo systemctl status whisperweb.service

The following article has some great explanations on what different options in the unit file mean and do.

https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/

Snapper reverting changes on Fedora

List snapper BTRFS snapshots with

snapper list

If you are in recovery mode on Fedora, add –no-dbus right after the snapper command. e.g.

snapper --no-dbus list

You can use the diff command to list the changes that happened between snapshots.

snapper --no-dbus diff 108..109

And to undo a change or all the changes between a snapshot, do the following. Where 108..109 are all the changes you want to remove. So essentially going back to snapshot 108.

snapper --no-dbus -v undochange 108..109

https://documentation.suse.com/sles/11-SP4/html/SLES-all/cha-snapper.html

Auto Start VM after XenServer reboot

SSH or gain command line access to XenServer

First we need to enable the Pool to allow auto starting
Second we will need to turn on the auto_poweron to true

In the following examples replace the UUIDs with your UUIDs

Find Pool UUID

You can find the pool UUID by running the “xe pool-list” Command. Note: you’ll still have a pool even if there is only a single server.

# xe pool-list
uuid ( RO) : 2e587aeb-de94-hf29-3eda-923d8he634fe

Enable auto_poweron for the pool

xe pool-param-set uuid=2e587aeb-de94-hf29-3eda-923d8he634fe other-config:auto_poweron=true

Verify that it is enabled

xe pool-param-list uuid=2e587aeb-de94-hf29-3eda-923d8he634fe  | grep auto_poweron

List VM UUID’s

Locate the UUID’s of the VM’s you want to start

# xe vm-list
uuid ( RO)           : 521be58a-3495-ea29-02a0-85ffcda06583
     name-label ( RW): CentOS 7
    power-state ( RO): running

Enable auto start

Run the following command for each VM you want to auto start. Change the UUID to the UUID of the vm you want to start.

xe pool-param-set uuid=521be58a-3495-ea29-02a0-85ffcda06583  other-config:auto_poweron=true

Print parameter settings

Use the following command to verify that the auto_poweron option is enabled.

xe vm-param-list uuid=521be58a-3495-ea29-02a0-85ffcda06583 | grep -i poweron | cut -d";" -f1

Example output

                      other-config (MRW): auto_poweron: true

https://support.citrix.com/article/CTX133910

Issues installing or repairing Windows 10

Error : Windows could no prepare the computer to boot into the next phase of the installation
Notes : This happens right after you finish partitioning and installation never gets past 0%
Fix : Disconnect all drives except the drive you want to install Windows 10.  This includes laptops.

Issue : Can’t reach login screen
Notes : Can happen after an update, auto repair should fix it
Fix : Start up the computer normal and when it starts to load windows force shutdown the computer.  Repeat the process 2 times, on the third start up it will Automatically try to fix the issue.

Other Issues

Windows 10 seems to be a little weird when you have two installs on two different drives and your trying to repair one.  I have had issues when trying to repair one, or boot into safe mode.  Removing all other other drives seems to resolve most of the issues.

Issues with multiple drives with an install of Windows 10

  • Reset Drive resets the wrong drive
  • Boot into safemode doesn’t work