Can we configure Theia to be runned after reboot using theia.service?

Im running Theia with this command:
yarn theia start /home/centos/my-workspace --hostname --port 8080 &

Can you guys show me how i would have to configure theia.service file if its possible?

For nginx is easy:

Description=nginx - high performance web server

ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/conf/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID


[original thread by dmirc]


I tried with cron job. And its so annoying. Simple stuff should work immediate but:

vim /etc/crontab


* * * * * root cd /opt/my-app && /root/.nvm/versions/node/v8.15.1/bin/yarn theia start /home/centos/my-workspace --hostname --port 8080 &>/tmp/mycommand.log &

Many things tried, i am always getting error:
/usr/bin/env: node: No such file or directory

btw, command is working from command line runned as root.


Solved the cron job issue:

vim /etc/crontab

@reboot root “/opt/my-app/” &>/tmp/mycommand.log &

in bash script:


. $HOME/.bashrc
cd /opt/my-app && /root/.nvm/versions/node/v8.15.1/bin/yarn theia start /home/centos/my-workspace --hostname --port 8080