Help troubleshooting a custom service
I want to setup my machine running Ubuntu Server to automatically run abcde
when a disc is inserted.
/usr/local/bin/discready
returns 0 when a disc is waiting to be read, returns non-zero otherwise
/usr/local/bin/autorip
runsdiscready
, checks for a 0 exit code every 15 seconds, and runsabcde
when that condition is met.
/etc/systemd/system/autorip.service
was created using instructions from this article
/usr/local/bin/discready
script:
#!/usr/bin/python3
# usage: DEVICE=/dev/sr0 discready
import fcntl
import os
import sys
DEFAULT_DEVICE = '/dev/cdrom'
STATUSES = ['NA', 'NO_DISK', 'OPEN', 'READING', 'DISC']
def drive_status(device):
# https://superuser.com/a/1367091/1001393
file = os.open(device, os.O_RDONLY | os.O_NONBLOCK)
status = fcntl.ioctl(file, 0x5326)
os.close(file)
return status
if __name__ == '__main__':
device = os.environ.get('DEVICE', DEFAULT_DEVICE)
status_num = drive_status(device)
status = STATUSES[status_num]
if status_num == STATUSES.index('DISC'):
sys.exit(0)
print(f'Device: {device}, Status: {status}')
sys.exit(status_num)
/usr/local/bin/autorip
script:
#!/usr/bin/env bash
# wait for discready to return a zero exit code, run abcde
while true; do
discready
result=$?
[ $result -eq 0 ] && abcde -N
sleep 15
done
/etc/systemd/system/autorip.service
Description=autorip
After=network.target
[Service]
Type=simple
User=rd
WorkingDirectory=/home/rd
ExecStart=/home/rd/autorip
Restart=always
[Install]
WantedBy=multi-user.target
output of systemctl status autorip.service
● autorip.service - autorip
Loaded: loaded (/etc/systemd/system/autorip.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-02-24 05:22:36 UTC; 18min ago
Process: 20642 ExecStart=/home/rd/autorip (code=exited, status=203/EXEC)
Main PID: 20642 (code=exited, status=203/EXEC)
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Main process exited, code=exited, status=203/EXEC
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Failed with result 'exit-code'.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Service RestartSec=100ms expired, scheduling restart.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Scheduled restart job, restart counter is at 5.
Feb 24 05:22:36 kingwin systemd[1]: Stopped autorip.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Start request repeated too quickly.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Failed with result 'exit-code'.
Feb 24 05:22:36 kingwin systemd[1]: Failed to start autorip.
autorip
works exactly as I want when running in the terminal. Attempting to turn this into a service is where I'm getting tripped up. Is it because discready is returning a non-zero exit code? Any troubleshooting tips or pointers would be greatly appreciated.
server systemd services 18.10
New contributor
add a comment |
I want to setup my machine running Ubuntu Server to automatically run abcde
when a disc is inserted.
/usr/local/bin/discready
returns 0 when a disc is waiting to be read, returns non-zero otherwise
/usr/local/bin/autorip
runsdiscready
, checks for a 0 exit code every 15 seconds, and runsabcde
when that condition is met.
/etc/systemd/system/autorip.service
was created using instructions from this article
/usr/local/bin/discready
script:
#!/usr/bin/python3
# usage: DEVICE=/dev/sr0 discready
import fcntl
import os
import sys
DEFAULT_DEVICE = '/dev/cdrom'
STATUSES = ['NA', 'NO_DISK', 'OPEN', 'READING', 'DISC']
def drive_status(device):
# https://superuser.com/a/1367091/1001393
file = os.open(device, os.O_RDONLY | os.O_NONBLOCK)
status = fcntl.ioctl(file, 0x5326)
os.close(file)
return status
if __name__ == '__main__':
device = os.environ.get('DEVICE', DEFAULT_DEVICE)
status_num = drive_status(device)
status = STATUSES[status_num]
if status_num == STATUSES.index('DISC'):
sys.exit(0)
print(f'Device: {device}, Status: {status}')
sys.exit(status_num)
/usr/local/bin/autorip
script:
#!/usr/bin/env bash
# wait for discready to return a zero exit code, run abcde
while true; do
discready
result=$?
[ $result -eq 0 ] && abcde -N
sleep 15
done
/etc/systemd/system/autorip.service
Description=autorip
After=network.target
[Service]
Type=simple
User=rd
WorkingDirectory=/home/rd
ExecStart=/home/rd/autorip
Restart=always
[Install]
WantedBy=multi-user.target
output of systemctl status autorip.service
● autorip.service - autorip
Loaded: loaded (/etc/systemd/system/autorip.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-02-24 05:22:36 UTC; 18min ago
Process: 20642 ExecStart=/home/rd/autorip (code=exited, status=203/EXEC)
Main PID: 20642 (code=exited, status=203/EXEC)
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Main process exited, code=exited, status=203/EXEC
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Failed with result 'exit-code'.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Service RestartSec=100ms expired, scheduling restart.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Scheduled restart job, restart counter is at 5.
Feb 24 05:22:36 kingwin systemd[1]: Stopped autorip.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Start request repeated too quickly.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Failed with result 'exit-code'.
Feb 24 05:22:36 kingwin systemd[1]: Failed to start autorip.
autorip
works exactly as I want when running in the terminal. Attempting to turn this into a service is where I'm getting tripped up. Is it because discready is returning a non-zero exit code? Any troubleshooting tips or pointers would be greatly appreciated.
server systemd services 18.10
New contributor
add a comment |
I want to setup my machine running Ubuntu Server to automatically run abcde
when a disc is inserted.
/usr/local/bin/discready
returns 0 when a disc is waiting to be read, returns non-zero otherwise
/usr/local/bin/autorip
runsdiscready
, checks for a 0 exit code every 15 seconds, and runsabcde
when that condition is met.
/etc/systemd/system/autorip.service
was created using instructions from this article
/usr/local/bin/discready
script:
#!/usr/bin/python3
# usage: DEVICE=/dev/sr0 discready
import fcntl
import os
import sys
DEFAULT_DEVICE = '/dev/cdrom'
STATUSES = ['NA', 'NO_DISK', 'OPEN', 'READING', 'DISC']
def drive_status(device):
# https://superuser.com/a/1367091/1001393
file = os.open(device, os.O_RDONLY | os.O_NONBLOCK)
status = fcntl.ioctl(file, 0x5326)
os.close(file)
return status
if __name__ == '__main__':
device = os.environ.get('DEVICE', DEFAULT_DEVICE)
status_num = drive_status(device)
status = STATUSES[status_num]
if status_num == STATUSES.index('DISC'):
sys.exit(0)
print(f'Device: {device}, Status: {status}')
sys.exit(status_num)
/usr/local/bin/autorip
script:
#!/usr/bin/env bash
# wait for discready to return a zero exit code, run abcde
while true; do
discready
result=$?
[ $result -eq 0 ] && abcde -N
sleep 15
done
/etc/systemd/system/autorip.service
Description=autorip
After=network.target
[Service]
Type=simple
User=rd
WorkingDirectory=/home/rd
ExecStart=/home/rd/autorip
Restart=always
[Install]
WantedBy=multi-user.target
output of systemctl status autorip.service
● autorip.service - autorip
Loaded: loaded (/etc/systemd/system/autorip.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-02-24 05:22:36 UTC; 18min ago
Process: 20642 ExecStart=/home/rd/autorip (code=exited, status=203/EXEC)
Main PID: 20642 (code=exited, status=203/EXEC)
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Main process exited, code=exited, status=203/EXEC
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Failed with result 'exit-code'.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Service RestartSec=100ms expired, scheduling restart.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Scheduled restart job, restart counter is at 5.
Feb 24 05:22:36 kingwin systemd[1]: Stopped autorip.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Start request repeated too quickly.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Failed with result 'exit-code'.
Feb 24 05:22:36 kingwin systemd[1]: Failed to start autorip.
autorip
works exactly as I want when running in the terminal. Attempting to turn this into a service is where I'm getting tripped up. Is it because discready is returning a non-zero exit code? Any troubleshooting tips or pointers would be greatly appreciated.
server systemd services 18.10
New contributor
I want to setup my machine running Ubuntu Server to automatically run abcde
when a disc is inserted.
/usr/local/bin/discready
returns 0 when a disc is waiting to be read, returns non-zero otherwise
/usr/local/bin/autorip
runsdiscready
, checks for a 0 exit code every 15 seconds, and runsabcde
when that condition is met.
/etc/systemd/system/autorip.service
was created using instructions from this article
/usr/local/bin/discready
script:
#!/usr/bin/python3
# usage: DEVICE=/dev/sr0 discready
import fcntl
import os
import sys
DEFAULT_DEVICE = '/dev/cdrom'
STATUSES = ['NA', 'NO_DISK', 'OPEN', 'READING', 'DISC']
def drive_status(device):
# https://superuser.com/a/1367091/1001393
file = os.open(device, os.O_RDONLY | os.O_NONBLOCK)
status = fcntl.ioctl(file, 0x5326)
os.close(file)
return status
if __name__ == '__main__':
device = os.environ.get('DEVICE', DEFAULT_DEVICE)
status_num = drive_status(device)
status = STATUSES[status_num]
if status_num == STATUSES.index('DISC'):
sys.exit(0)
print(f'Device: {device}, Status: {status}')
sys.exit(status_num)
/usr/local/bin/autorip
script:
#!/usr/bin/env bash
# wait for discready to return a zero exit code, run abcde
while true; do
discready
result=$?
[ $result -eq 0 ] && abcde -N
sleep 15
done
/etc/systemd/system/autorip.service
Description=autorip
After=network.target
[Service]
Type=simple
User=rd
WorkingDirectory=/home/rd
ExecStart=/home/rd/autorip
Restart=always
[Install]
WantedBy=multi-user.target
output of systemctl status autorip.service
● autorip.service - autorip
Loaded: loaded (/etc/systemd/system/autorip.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-02-24 05:22:36 UTC; 18min ago
Process: 20642 ExecStart=/home/rd/autorip (code=exited, status=203/EXEC)
Main PID: 20642 (code=exited, status=203/EXEC)
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Main process exited, code=exited, status=203/EXEC
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Failed with result 'exit-code'.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Service RestartSec=100ms expired, scheduling restart.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Scheduled restart job, restart counter is at 5.
Feb 24 05:22:36 kingwin systemd[1]: Stopped autorip.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Start request repeated too quickly.
Feb 24 05:22:36 kingwin systemd[1]: autorip.service: Failed with result 'exit-code'.
Feb 24 05:22:36 kingwin systemd[1]: Failed to start autorip.
autorip
works exactly as I want when running in the terminal. Attempting to turn this into a service is where I'm getting tripped up. Is it because discready is returning a non-zero exit code? Any troubleshooting tips or pointers would be greatly appreciated.
server systemd services 18.10
server systemd services 18.10
New contributor
New contributor
New contributor
asked 15 mins ago
RichardRichard
1012
1012
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Richard is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1120783%2fhelp-troubleshooting-a-custom-service%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Richard is a new contributor. Be nice, and check out our Code of Conduct.
Richard is a new contributor. Be nice, and check out our Code of Conduct.
Richard is a new contributor. Be nice, and check out our Code of Conduct.
Richard is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1120783%2fhelp-troubleshooting-a-custom-service%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown