diff --git a/api/api.service b/api/api.service new file mode 100644 index 0000000..2d1e07d --- /dev/null +++ b/api/api.service @@ -0,0 +1,16 @@ +[Unit] +Description=Api +After=network-online.target + +[Service] +Type=simple +Restart=on-failure + +User=node +Group=node + +WorkingDirectory=/home/node/app +ExecStart=/usr/bin/node /home/node/app/dist/index.js + +[Install] +WantedBy=multi-user.target diff --git a/api/src/index.ts b/api/src/index.ts index 1ac6047..2bd8c64 100644 --- a/api/src/index.ts +++ b/api/src/index.ts @@ -4,6 +4,6 @@ import express from 'express'; const app = express(); app.use(express.json()); app.use(cors()); -app.get('/', (req, res) => res.send('coucou\n')); +app.get('/', (req, res) => res.send('coucou ?\n')); app.listen(8000, () => console.log('running...')); diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..12e6602 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +useradd node -md /home/node -s /usr/sbin/nologin + +python3 install.py +python3 build.py + +rm -r /var/www/html/* +mv www/public/* /var/www/html + +mv api/api.service /etc/systemd/system +systemctl daemon-reload +systemctl enable api + +systemctl stop api +mkdir /home/node/app +rm -r /home/node/app/* +mv api/dist /home/node/app +mv api/node_modules /home/node/app +systemctl start api diff --git a/www/src/main.ts b/www/src/main.ts index f13a50b..4a5f88a 100644 --- a/www/src/main.ts +++ b/www/src/main.ts @@ -3,7 +3,7 @@ import App from './App.svelte'; const app = new App({ target: document.body, props: { - name: 'tout le monde' + name: 'tout tout le monde' } });