For reasons I don't understand, Deno is not a systemd
service by default. It has an auto install script that drops the deno executable file in your /home
folder. When you deno run
a Typescript file using this executable, it loads up your script and them you can say goodbye to the console being used for anything else.
How do I add deno
as a systemd
service to Ubuntu?
YES! I figured it out!
Although, it would be really nice if you could help me figure out why deno
only executes if you are logged in as a root
user. I cannot get deno to run with sudo user.
Steps:
Install deno using the .sh
script they provide at deno.land
Copy your httpServer.ts
to your /home
directory.
Tell systemd
about the application by creating the service file we will be using.
sudo touch /etc/systemd/system/deno.service
Edit this recently created empty file using the template below.
[Unit]
Description=Deno 1.1.1 service
Documentation=http://deno.land
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=user1
WorkingDirectory=/home
ExecStart=/home/user1/.deno/bin/deno run --allow-net --allow-read httpServer.ts
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl enable deno
sudo systemctl start deno
sudo systemctl status deno
Screenshot